One of the most powerful aspects of using Vim is that you never have to do any drudge work. All boring repeatable tasks can be executed with a meaningful command. A recent problem I ran into was to create variable names with a large number of incrementally increasing indices. I found an awesome plugin by Dr. Chip called VisIncr that automates this very useful operation.
- Install: Use your favorite Vim plugin installation method to install this plugin from this URL: https://github.com/vim-scripts/VisIncr
Usage: Let us assume I want to generate variables ranging from
x_16. I first type
x_3and repeat it 13 times one on each line. Mark the column containing
3using visual block (
Ctrl+V). Then press
Iand press Enter. Boom! See the output in above image. The command
Iis easy to remember cause the operation is i-ncrement.
You can refer to the documentation for the commands to increment with right justification (default is left), by a different increment or want to increment octal number, Roman numerals or dates. Pretty much any scenario that appears in code is covered by the plugin.
Tried with: Vim 7.4 and Ubuntu 16.04