π 2017-Jan-17 ⬩ βοΈ Ashwin Nanjappa ⬩ π·οΈ vim ⬩ π Archive
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_3
to x_16
. I first type x_3
and repeat it 13 times one on each line. Mark the column containing 3
using visual block (Ctrl+V
). Then press I
and press Enter. Boom! See the output in above image. The command I
is 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