Saturday, March 5, 2011

Increment and decrement a number in vim

This tip will increment and decrement a number in vim editor.

(a) To increment, hit Ctrl+A
(b) To decrement, hit Ctlr+X

Suppose a number 5 is present in vim editor's buffer. Now, pressing Ctrl+A will increments the number by 1 i.e 6, again if you press Ctrl+A, 6 becomes 7 etc.. same way if you press Ctrl+X, the number will be decremented by 1.

Example:

Let's say, vim buffer contains a number 1

Ctrl+A increments to 2
10Ctrl+A increments to 11
5Ctrl+X decrements to 6
Ctrl+X decrements to 5

No comments:

Post a Comment