Robbie S.,
July 25, 2002 12:36
|
You can also press Ctrl+A in normal mode to increment numbers!
|
Anonymous,
July 26, 2002 4:00
|
You don't even need to be on the number itself. Vim search automaticaly for the next number before incrementing / decrementing
|
[email protected],
July 26, 2002 7:30
|
It should be noted that the 'nrformats' option dictates whether letters, octal and hexadecimal numbers are recognized and modified accordingly.
|
[email protected],
August 4, 2002 10:46
|
this
|
[email protected],
October 30, 2003 15:10
|
great tip! how do find things like this in the help file? I tried :help increment
|
jaldripublic at comcast.net,
November 16, 2003 0:02
|
:helpgrep subtract
|
jaldripublic @ comcast.net,
November 16, 2003 0:12
|
To use these keys (CTRL-A CTRL-X) on a selection (block of numbers), download vimscript #821.
This plugin also allows resequencing numbers in a selected list (example included on the script page).
|
[email protected],
March 8, 2004 7:43
|
... and if you have Perl, you can do tons with the s command, eg:
:%!perl -e 's/(\d+)/$1 + 1/ge'
will increment every number by one. the "e" at the end makes the right side of the substitution an expression. I find this handy for converting data to/from one-based to zero-based.
|
[email protected],
September 29, 2005 13:19
|
"Life changing" -- yes, but not in the way you meant.
I've been an emacs user for a loooooooong time but I often use vi/vim for quick edits. While editing a file which does some processing and then returns (programmatically) a web page, my fingers automatically typed "C-x C-s" (the emacs combo for saving a file) when the cursor was over the "200" argument (i.e. HTTP status code for a normal return). Realizing what my fingers had done, I then saved the document in a vim-approved way.
It wasn't until the next day when people were complaining about web pages not working and the access logs showed a lot of HTTP status codes of 199 that I realized that the code had changed in the source.
On a hunch that vim had some nifty feature, I googled for "vim decrement" and found this page.
|
Anonymous,
November 19, 2005 12:10
|
Beware of this feature if you are used to editing from within screen, and then edit a file not from within screen, try to switch windows (or do some other screen task), and find that not working. Some numbers in your file might be incremented. :-)
|
Anonymous,
March 13, 2006 23:09
|
If you use vim under 'screen', press "control-a", then hit "a". Screen then sends on a translation of 'control-a' to the underlying program - vim.
|