Sunday, November 4, 2012

Snippet for adding closing parentheses in ultisnips

Hi!

I have the following definition in my .vimrc to easily type
parentheses.

inoremap ( (<C-R>=UltiSnips_Anon('($1)$0', '(')<CR>

This snippet does the following: Whenever I type an open parentheses
it adds a closing one and positions the cursor in between. With
<Ctrl-j> I can jump after the closing parentheses. This, however,
works only if I place a space between the function and the open
parentheses.

main () // works, the closing parentheses is added
main( // fails without space

A simple check with

inoremap ( ()

shows that the mapping is triggered with and without space, so the
problem is the snippet, not the mapping.

How can I fix the snippet to work with and without space after
the function name? Or is there a better way to achieve that?


Marco


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment