我们如何使用VIM编辑器以递增顺序制作具有十六进制数字模式的文本文件? 我需要一个如下图案:
0000
0001
0002
....
0008
0009
000A
000B
....
000F
0010
0011
....
FFFF
可以重复操作吗?
答案 0 :(得分:5)
:put =map(range(0,65535), 'printf(''%04x'', v:val)')
答案 1 :(得分:1)
一种解决方案是创建一个宏。 <c-a>
会将光标下的数字增加1.如果数字以0x
开头,则会将其解释为十六进制数。
来自文档:h CTRL-A
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 register '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. <count>@a - repeat the yank, put and increment <count> times
单词后,您可能需要从数字中删除0x
并将其设为大写。