用Vim产生序号

用Vim在一段文字前加上序列号

 

 

merged latest T3 fixes from erp-trunk
applied QAD 2011 EE finance patch 1
applied QAD warehousing percent field renaming fix
loaded latest system test data from erp-trunk
loaded latest QXtend events db schema
fixed NETUI homeserver and connection manager configuration error
enabled Oracle auto-start
enlarged disk space to 60G

 

 

使它变成

 

 

1. merged latest T3 fixes from erp-trunk
2. applied QAD 2011 EE finance patch 1
3. applied QAD warehousing percent field renaming fix
4. loaded latest system test data from erp-trunk
5. loaded latest QXtend events db schema
6. fixed NETUI homeserver and connection manager configuration error
7. enabled Oracle auto-start
8. enlarged disk space to 60G

 

 

使用Vim的record功能。

第一步,在文本加一行文字内容为0,变成如下:

 

0
merged latest T3 fixes from erp-trunk
applied QAD 2011 EE finance patch 1
applied QAD warehousing percent field renaming fix
loaded latest system test data from erp-trunk
loaded latest QXtend events db schema
fixed NETUI homeserver and connection manager configuration error
enabled Oracle auto-start
enlarged disk space to 60G

 

第二步,光标移动到第二行,按”qa"进入录制模式,接着按“0”把光标定位到第一列,按"k"到上一行,按"yw"复制上一行序号,按"j"回到原来的行,按"P"黏贴上一行序号,按”a"进入编辑模式,并在序号后加上点和空格。按"ESC"回到命令模式,按"0"回到首列,按“Ctrl-A"增加序号,按“j"把光标移到下一行。按"q"结束录制。然后就可以使用7@a给剩下的文本加上序号了。完整的录制按键序列为"qa0kywjPa. <ESC>0<ctrl-A>jq"

 

如果需要用字母作为序号,那么先要确保nrformats设置中包含alpha选项。:set nrformats+=alpha。

注意,Windows下的vim Ctrl-A是全选,需把mswin.vim中的如下内容注释

 

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG

 成:

 

" CTRL-A is Select all
"noremap <C-A> gggH<C-O>G
"inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
"cnoremap <C-A> <C-C>gggH<C-O>G
"onoremap <C-A> <C-C>gggH<C-O>G
"snoremap <C-A> <C-C>gggH<C-O>G
"xnoremap <C-A> <C-C>ggVG

 或者临时性不加载mswin.vim文件。

 

你可能感兴趣的:(oracle,C++,c,C#,vim)