Key to finish snippet and go to caret/finish place?

13 views
Skip to first unread message

Martin Lundberg

unread,
Apr 15, 2011, 11:40:40 AM4/15/11
to xptem...@googlegroups.com
Hi,

Is there a key which you can hit to finish the snippet without going through all of the tab stops and which makes the caret go to the caret finish place? If so, how would I map that to ENTER?

Thanks,

-Martin

dr-dr xp

unread,
Apr 16, 2011, 1:54:12 AM4/16/11
to xptem...@googlegroups.com
There is a command to do this:
XPTcrash
It is safe to use at any time when you want to finish snippet.


--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.



--
要了几天饱饭就不记得西北风啥味了

Martin Lundberg

unread,
Apr 16, 2011, 6:02:59 AM4/16/11
to xptem...@googlegroups.com
How would I map it so that it is run when I hit ENTER when I've triggered a xptemplate? I allready have it mapped to <c-]> to be able to follow tags with it. But if it is possible to make it do both it would be really good.

dr-dr xp

unread,
Apr 16, 2011, 9:32:03 AM4/16/11
to xptem...@googlegroups.com
If you want pressing ENTER to finish snippet, first you need to change a setting:
let g:xptemplate_nav_cancel = "otherkey"
Because it is a mapping added when snippet starts.

And then :
inoremap <CR> <ESC>:XPTcrash

Not sure if it is what you want.

On Sat, Apr 16, 2011 at 6:02 PM, Martin Lundberg <martin....@gmail.com> wrote:
How would I map it so that it is run when I hit ENTER when I've triggered a xptemplate? I allready have it mapped to <c-]> to be able to follow tags with it. But if it is possible to make it do both it would be really good.

--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.



--
要了几天饱饭就不记得西北风啥味了

Martin Lundberg

unread,
Apr 17, 2011, 3:36:50 AM4/17/11
to xptem...@googlegroups.com
Sorry for once again being a little bit annoyinng but my <cr> key is usually already mapped like this:

inoremap <expr> <CR> pumvisible() ?
 \ "\<C-Y>" : delimitMate#WithinEmptyPair() ?
 \ "\<C-R>=delimitMate#ExpandReturn()\<CR>" : "\<C-G>u\<CR>"

So I can use <cr> to finish a popup and also since the plugin delimitMate also uses it I've added some special handling with the help f the plugin developer. But since pressing <cr> now inside a xptemplate works to cancel and move to the next placeholder it seems as if I should be able to add this mapping without affecting my otther mapping of <cr>?

dr-dr xp

unread,
Apr 17, 2011, 7:11:03 AM4/17/11
to xptem...@googlegroups.com
Seems not possible to bind so many functions together into a single <CR>.

--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.



--
要了几天饱饭就不记得西北风啥味了

Martin Lundberg

unread,
Apr 17, 2011, 11:36:01 AM4/17/11
to xptem...@googlegroups.com
On Sunday, April 17, 2011 1:11:03 PM UTC+2, dr-dr xp wrote:
Seems not possible to bind so many functions together into a single <CR>.

But it works right now for "cancel and go to next placeholder" shouldn't it work for cancel and go to cursor then? 

Martin Lundberg

unread,
Apr 18, 2011, 7:25:33 AM4/18/11
to xptem...@googlegroups.com
I take that back. The cancel and go to next placeholder does not seem to work with ENTER. Sorry about that. I'll try to look into it some more myself.

Martin Lundberg

unread,
Apr 19, 2011, 3:39:26 AM4/19/11
to xptem...@googlegroups.com


On Sunday, April 17, 2011 1:11:03 PM UTC+2, dr-dr xp wrote:
Seems not possible to bind so many functions together into a single <CR>.
 
 I've decided not to match <cr> to <C-]> and use the original mapping to move to tags instead. What about if I only want to combine the delimitMate and xptemplate behaviour? Would that be possible? 

Martin Lundberg

unread,
Apr 19, 2011, 3:43:13 AM4/19/11
to xptem...@googlegroups.com
I see now that that pretty much don't matter since it's <cr> in insert mode which is mapped to too much. I'll put on the thinking hat again.

Martin Lundberg

unread,
Apr 20, 2011, 2:18:18 AM4/20/11
to xptem...@googlegroups.com
Hello again :)

With help of a friend I converted my mapping to a function which now looks like https://gist.github.com/930480 (with added echom for debugging). However even though I've added let g:xptemplate_nav_cancel = "<c-c>" to my .vimrc a <cr> inside a snippet just adds a newline and does not run the function. I found that the line probably casuing this is: https://github.com/drmingdrmer/xptemplate/blob/master/dist/plugin/xptemplate.vim#L2272 which seem to make it impossible to use <CR> for something like what I want?

Best wishes,

Martin
Reply all
Reply to author
Forward
0 new messages