October 2012
346 pages
7h 40m
English
| Tip 10 | Use Counts to Do Simple Arithmetic |
Most Normal mode commands can be executed with a count. We can exploit this feature to do simple arithmetic.
Many of the commands that are available in Normal mode can be prefixed with a count. Instead of executing the command just once, Vim will attempt to execute the command the specified number of times (see count
).
The <C-a> and <C-x> commands perform addition and subtraction on numbers. When run without a count they increment by one, but if we prefix a number, then we can add or subtract by any whole number. For example, if we positioned our cursor on a 5 character, running 10<C-a> would modify ...
Read now
Unlock full access