3

I am using neocomplcache along with neosnippet and honza's vim-snippets. They are great, except that when I press Ctrl-k, I can go to the next parameter, but I have no way to go back to the previous parameter.

So for example, if I inserted 'for' snippet and made a typo on the index variable, but I already pressed Ctrl-k, am I screwed? Must I go through modifications of all the parameters and then come back to do replace operation? Or is there mapping for select mode that I can help me in this situation? Currently Tab and S-Tab do not do anything.

Lastly, are all snippet plugins like this? Or is neocomplcache just missing this feature (out of the box, at least)?

2 Answers 2

10

I encourage you to try UltiSnips. It is much more powerful and mature than vim-snippets or neosnippet. For instance, since UltiSnips is based on Python, it is very extensible. Concerning your problem: yes, you can jump back and forth with UltiSnips. Finally, be sure to check out screencasts (listed in the link) to see all the fancy stuff you can do with it.

For example, I use the following configuration:

let g:UltiSnipsSnippetsDir        = '~/.vim/snippets/'
let g:UltiSnipsSnippetDirectories = ['UltiSnips', 'snippets']

let g:UltiSnipsExpandTrigger       = '<C-CR>'
let g:UltiSnipsJumpForwardTrigger  = '<A-d>'
let g:UltiSnipsJumpBackwardTrigger = '<A-a>'

NOTE: ~/.vim/snippets/ is my directory for custom snippets.

As I've already mentioned UltiSnips uses Python extensively, and therefore requires Vim to be built with Python support. If you are on Windows (especially x64), that might be a trouble, the one I've run into quite some time ago. To save yourself precious time and avoid frustration you may consider downloading my Vim for Windows. Both x86 and x64 architectures are provided, and it supports both Python 2 and Python 3 simultaneously. I can assure you that it is stable. To install properly just follow the instructions. These builds are updated frequently.

6
  • 1
    I feel this should be comment, not answer. and how do you define "mature" ?
    – Kent
    Commented Apr 12, 2013 at 23:21
  • @Kent: I define it as being stable/extensible/providing useful set of features by default. As long as author asks about other plugins, I gave him my personal recommendation which works well for me and solves his problem in the first place. Commented Apr 12, 2013 at 23:24
  • sorry, just now I didn't see OP's last sentence in question.. btw, UltiSnips is nice plugin for sure. but I don't think it is more mature than vim-snippets. I feel a product/application mature, we have to see how long has it been active in market or industry, how many users etc. for example. Sublimtext2 and vim both are good editors, but vim is more mature, if we compare both. well it is just my private opinion.
    – Kent
    Commented Apr 12, 2013 at 23:30
  • @Haroogan Okay. I compiled vim with python and finally got Ultisnips to work with neocomplcache using JazzCore's plugin, but I still cannot jump back. Which keybinding are you using? I checked both :smap and :nmap to make sure I do not have any prev bindings. Please note that I use cygwin(+mintty), although I do not think this will be a problem. Commented Apr 13, 2013 at 21:58
  • @Prometheus: You may also check my Vim Configuration in general, maybe you'll find some interesting and helpful stuff for yourself. Commented Apr 13, 2013 at 22:12
2

The original SnipMate and its fork (the plugins for which vim-snippets is actually meant to be) both allow you to go back to the previous placeholder with <S-Tab>. I believe UltiSnips does too.

Neocomplcache doesn't support snippet expansion out of the box anymore. AFAIK, you need another plugin by the same author called neosnippet which is the one responsible for the <C-k> mapping. A quick look at the doc shows no "reverse jump" mapping, function or command. You can probably create a new issue on neosnippet's Github page.

2
  • SnipMate is good and tried it out, but I want to mention that it is being deprecated slowly in favor of Ultisnip, endorsed by one of the maintainers, Marc. I had no trouble using SnipMate though. The neocomplcacahe's github page has this feature request open. The author states the complexity involved and no one is working on the problem. Commented Apr 14, 2013 at 10:23
  • 1
    Well… there's no central authority deciding if a plugin is deprecated or not and if there was one, Marc Weber would probably not be that authority anyway. Fashionable != standard and unmaintained != deprecated. I've been using the original SnipMate without problems since a long time and see no reason to change.
    – romainl
    Commented Apr 14, 2013 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.