蚂蚁的天空

Practice make Perfect.

星期一, 四月 09, 2007

用VIM命令逐行翻转文件内容和列出关键字的上下文


假设有这样一个文件:


line 1
line 2
line 3
...
line N



想要把它翻转成这样:


line N
line N-1
...
line 3
line 2
line 1


今天看了一个TIP,可以这样做:


:g/^/m0|nohl


还可以列出上下文:


:g/<pattern>/z#.5|echo "==="|nohl


这样就把<pattern>所在行的上下两行都列出来了。




Technorati :

0 Comments:

发表评论

Links to this post:

创建链接

<< Home