Cool trick to change numbers
From Vim Tips Wiki
[edit] Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
Tip 287 Previous Next Created: July 25, 2002 Complexity: basic Author: Nitya Version: 5.7
To decrement a number, switch to normal mode, place your cursor on it, and press <CTRL-X>. Similarly, use <CTRL-A> to increment it.
The 'nrformats' option controls whether letters, octal and hexadecimal numbers are recognized and modified accordingly. The default value of nrformats is "octal,hex" so numbers that start with 0 are assumed to be octal, and numbers that start with 0x or 0X are assumed to be hexadecimal. :set nrformats+=alpha allows these keys to increment and decrement letters of the alphabet.
[edit] References
[edit] Related plugin
These keys (<CTRL-A>, <CTRL-X>) can be used on a visual selection by using script#821. This plugin also allows resequencing numbers in a selected list (example included on the script page).
[edit] Interaction with other applications or plugins
- If you use vim under screen, press <CTRL-A> and then hit a. Screen then sends on a translation of <CTRL-A> to the underlying program - vim.
- Using mswin will override the behaviour of <CTRL-A> and <CTRL-X>. This overriding occurs frenquently on default installations of vim on Ms Windows platforms. See :help mswin.vim.
