I love things that make my programs act like vi when I need to edit or jump to things quickly. Among the vi addons I use are: viPlugin for Eclipse, viEmu for Visual Studio and SQL Server Management Studio, and Vimperator for Firefox.
I was coding on a rather large project recently using Zend Studio for Eclipse with viPlugin. It adds vi functionality to Eclipse, which is really handy for coding. I was talking to Chris Weldon about it and how I wanted to have the ability to copy multiple lines of code into reusable buffers. I use snippets in Visual Studio for this same functionality, and I knew vi had a way to do it, but I had forgotten what it did.
Introducing buffers… Buffers are vi’s answer to snippets. By default, any time you delete, yank, or change an open file, that line is saved in the default buffer. But you can add your own custom buffers using the ” character. Example: “ayy would yank the current line into a buffer name “a”. To reuse that buffer, simply execute in command mode: “ap to paste below or “aP to append to the current position. Buffers are a great way to increase your efficiency when you absolutely have to repeat lines multiple times (say across multiple files).
I also showed Chris how to use marks, which are basically bookmarks in a document. Marks are added to a document using ‘<mark_name> (single quote – mark name). Example: If you are on line 50 of a file, and you do ‘a and then jump to line 75 (75gg), you can easily jump back to line 50 using ma (go to mark “a”). Both IDEs that I use regularly (Visual Studio and Eclipse) have bookmark functionailty built in, but it is generally a much more involved process to add and jump to bookmarks.
There is one caveat to using viPlugin and viEmu – they don’t allow you to show registers and saved bookmarks! Another vi plugin I use for Firefox (Vimperator) does allow you to show saved bookmarks and registers by using the standard vim commands :bookmarks and :registers, respectively. I have filed bug reports for them and hope to see this functionality appear soon!