vim奇技淫巧之orderd list

vim写markdown时需要写ordered list, 虽然前面的数字会在渲染时自动规范,但毕竟如果能自动生成编号岂不更好?

首先键入内容, 不带前面的数字:

1
2
3
4
first item
second item
third item
fourth item

CTRL-v进入 可视块 模式,选定最左边一列,再按 I(大写)进入行首插入模式,键入 0. , 返回Normal模式, 你就发现每一行的行首都加了 0. ,如下:

1
2
3
4
0. first item
0. second item
0. third item
0. fourth item

这样是不是差不多是 多点编辑 了?

然后按 V 大写 进入 可视行 模式, 选定相关行,按 gCTRL-a,完成!

1
2
3
4
1. first item
2. second item
3. third item
4. fourth item