vim ultisnips reactivate snipet - vim

I'm a vim/ultisnips newbie trying to be more efficient when writing and coding. I've successfully installed the ultisnips plugin and it works so far.
My question is: is it possible to "reactivate" a snippet after it has been filled? The documentation says:
UltiSnips will only map the jump triggers while a snippet is active to
interfere as little as possible with other mappings.
But actually I would like to reactivate a snippet from time to time in order to efficiently jump between the placeholders while updating/modifying the snippet content.
Any idea how this can be done?

Related

snippet in vim - any option to go back to the previous parameter?

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)?
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.
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.

Expanding a snippet within a snippet (vim or sublime)

I'm trying to improve my work flow a little bit and I'm trying to accomplish something but don't really know where to start.
I'm a huge fan of snippets, I've been customizing lots of my own, and it really helps me write code much faster, and actually avoid errors as well.
However, I'd like to be able to expand a snippet while I'm still tabbing through a current snippet.
Any idea what I might be able to do? Is there a version of snippets for vim that does this? Is there a key binding I can put into sublime that might help?
Thanks!!!
I am not sure about snipmate but you definitely can do that with Ultisnips.

Adding vim snippets

I have found this resource for Ruby/Rails snippets, seems like it has lots of cool snippets that I could use with vim.
But since I'm new to vim, I don't know how to enable those snippets to my vim editor. There is no instruction manual as such.
How can I get these kind of snippets enabled in the vim editor?
Those snippets are for the snipMate - TextMate-style snippets for Vim plugin. You need to install it first.
Note that though this plugin isn't maintained any more, it's still working fine (and probably will continue to do so, due to Vim's great record of backwards compatibility), and is still used by many people (me included). There's a renewed fork available, though: garbas/vim-snipmate. A newer, more powerful plugin is UltiSnips - The ultimate snippet solution for python enabled Vim, which can convert the old snipMate snippets into its format. So, there's a lot of choice.
About Snippet Plugin in Vim
I recommend the plugin Neosnippets: https://github.com/Shougo/neosnippet This is the best in my opinion.
Step 1: Install plugin. Recommend using Pathogen to install
step 2: Download/clone a snippet repo you like to local machine, or create your own(recommeneded)
Step 3: Set the path of above repo as Neosnippets's snippets folder in vimrc
let g:neosnippet#snippets_directory='~/path/to/above/snippets/'
Step 4: Customize more if you like, according to the help file.
For the repo you mentioned
I checked it.
One problem is it's out of date, many Rails code are several years ago. They are of little use now.
The other problem is the format is not compatible with NeoSnippet. You can check :help neosnippet-snippet-syntax for how to write snippets for NeoSnippets. It's simple while easy to use.

Vim: How to set up an efficient autocomplete configuration?

I've been using Vim for a while now and love it, but one thing I've noticed when I use other editors is that I've never really got autocomplete working with much efficiency. I have supertab & snipmate working, I have tags for whatever language I'm using set up, but somehow it seems a little too cumbersome to use all that much, and apart from long method names I typically just avoid autocomplete.
Does anyone have fast, comprehensive autocomplete funcitonality set up in vim? Specifically:
At the moment, I hit "tab" to autocomplete class/method/variable names & generate snippets, but Ctrl+X+O for inbuilt langauge commands. I'd rather press tab for everything.
The ordering doesn't seem to be too intelligent. Very common stuff is often hidden in the middle of a bunch of rarely-used commands.
I've set up autocomplpop to show potential autocompletes as I'm typing, but I have to hit tab twice to accept the first entry. One much rather single-tab it.
So, any tips on setting up an efficient, comprehensive autocomplete configuration in vim? I know this question is a little vague - but if anyone has an overview of how they autocomplete well, and/or a link to a guide, it would be much appreciated.
Just thought I'd come back and mention that I finally found something I like: A customised version of NeoComplCache. Nice auto popup, everything integrated pleasantly into 'tab', and with a bit of customisation plays nice with snippets.
http://www.vim.org/scripts/script.php?script_id=2620
This is very dependant on your working domain. Vim is a text editor with the ability to interface with intelligent text-aware mechanisms.
If you are using java there is eclim, which is the eclipse backend together with a vim plugin for the frontend.
For C or C++ there is the plugin OmniCppComplete
It works by scanning the headers in the paths you have set up in vim (see :h path), and works very well imo.
If you have to press Ctrl-X_Ctrl-O for omnicompleteion, then your supertab config seems a bit broken. It should try omni or filename completion first, and then fall back to word completion.
YouCompleteMe plugin by Valloric is a very decent plugins for autocomplete and suggestion.
It contains support for all the major languages and you can extend the feature with setting up different engine .
it also comes with syntax checker so u don't have to use Syntastic separately
For setup details visit this link
https://github.com/Valloric/YouCompleteMe

What's the best thing you've done with vim that helped your programming?

While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!!
Can you people share what all cool things you have been doing in vim.
Edit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-opened to allow people to comment on any useful things that they've done using vim. For me? See my answer below. (-:
vim has a set of commands that integrate with development tools such as make, gcc, and ctags. You can build your project, navigate to warnings and errors, and jump to function/variable definitions without leaving the editor:
:make builds the project.
:cl lists warnings and errors.
:cc takes you to the to line in the source code that generated the current error.
:cn navigates to the next error.
:cp navigates to the previous error.
:tag name navigates to the definition of the token name. (See man ctags to generate an index of tokens; sometimes make tags will do this automatically.)
Pressing Ctrl+] navigates to the definition of the token under the cursor.
I'm using vim to syntax-color code in my blog and lecture notes. A single Perl line
system "$vimrt\\gvim.exe", qq{
-c "edit /tmp/tmpcode.$ext "
-c "source $vimrt/syntax/2html.vim"
-c "write! /tmp/tmpcode.html"
-c "qa!"};
converts the code into nicely-colored HTML. I know there are stand-alone tools for doing this, but vim is already installed on my system, so this is one less tool to install.
I found myself struggling to be more efficient in vim compared to other non-modal text editors until I learned about "text-objects". Understanding this concept really improved my productivity and also gave me a new way of looking at text which in turn made it easier to deeply understand other vim concepts that I had only understood ephemerally before.
:help text-objects
I was working on a system that had massive log files. We're talking 30,000 10MB logs.
Per day!
Distinguishing between log messages that were coming from the middleware (same company but custom rolled) and our application was getting tedious.
That is until I wrote some custom vim syntax parsing so that anything vim displayed in green was from the middleware (done by the guys in Sophia Antipolis near Cannes) as opposed to anything vim displayed in blue that was from our application software that sat over the top of the SA code.
I also added highlighting to really make exceptions stand out with white lettering on a read background!
Made life so much easier! And it wasn't that hard to do!
Thanks vim!
I couple of months ago I wrote a vim script to save a complete history of all my edits, so I could inspect and measure my programming performance.
I'm using vim a lot recently to edit XML files. I got the xmledit plugin for vim working. Now vim creates closing tags for me, I can enclose highlighted text in an XML tag, and jump to balancing XML tags. It saves a lot of repetitive typing, reduces mistakes, and increases my productivity.

Resources