Adding and subtracting
*CTRL-A*
CTRL-A Add [count] to the number or alphabetic character at
or after the cursor. {not in Vi}
*CTRL-X*
CTRL-X Subtract [count] from the number or alphabetic
character at or after the cursor. {not in Vi}
The CTRL-A and CTRL-X commands work for (signed) decimal numbers, unsigned
octal and hexadecimal numbers and alphabetic characters. This depends on the
'nrformats' option.
- When 'nrformats' includes "alpha", Vim will change the alphabetic character
under or after the cursor. This is useful to make lists with an alphabetic
index.
- When 'nrformats' includes "hex", Vim assumes numbers starting with '0x' or
'0X' are hexadecimal. The case of the rightmost letter in the number
determines the case of the resulting hexadecimal number. If there is no
letter in the current number, Vim uses the previously detected case.
- When 'nrformats' includes "octal", Vim considers numbers starting with a '0'
to be octal. Other numbers are decimal and may have a preceding minus sign.
If the cursor is on a number, the commands apply to that number; otherwise
Vim uses the number to the right of the cursor.
For numbers with leading zeros (including all octal and hexadecimal numbers),
Vim preserves the number of characters in the number when possible. CTRL-A on
"0077" results in "0100", CTRL-X on "0x100" results in "0x0ff". Note that
when 'nrformats' includes "octal", decimal numbers with leading zeros are
impossible because they are indistinguishable from octal numbers.
The CTRL-A command is very useful in a macro. Example: Use the following
steps to make a numbered list.
1. Create the first list entry, make sure it starts with a number.
2. qa - start recording into buffer 'a'
3. Y - yank the entry
4. p - put a copy of the entry below the first one
5. CTRL-A - increment the number
6. q - stop recording
7.@a - repeat the yank, put and increment times
2008/12/18
VIM is so cool
VIM is really cool, you can increase/decrease a number in the text directly by with CTRL-A and CTRL-X!
订阅:
博文评论 (Atom)
BlockChain 相关电子书
@copyright of Sam Chadwick - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper Blockchain Papers A c...
-
为Windows 10 添加 拼音加加双拼 输入方案 把下面的内容保存为 ppp.reg, 然后双击导入注册表,Pinyin PlusPlus双拼输入方案就有了。 Windows Registry Editor Version 5.00 [HKEY_CURRENT...
-
算起来到这里已经一年多了, 中间断断续续当然了也包括一些可观的原因,一共也没有放多少东西上来。 总算还有两片篇幅较长的原创,也算是聊以自慰了。 再接再厉好了!希望自己能够百尺竿头更进一步~~~
-
Today I do update the JavaScript syntax script for VIM to 0.7.2. Until now PRC 2007.01.30-21:37 my script got: Rating 332/99, Downloaded by ...
2 条评论:
vim often comes with surprise.
真是太酷了。
发表评论