VIM TIP29


VimTip 29: reverse all the line with only 7 keystroke in vim
使用7个键反转所有行

:g/^/m0
well,
1. : bring you to command-line mode(also known as ex-mode) from normal-mode(also known as command mode).
1. : 使你从一般模式进入命令行
2. g means you'll take an action through the whole file, generally perform a search, v' also perform a search but it match the line not match the canonical expression.<br>2.<b>g</b> 表明作用域将是整个文件,一般使用在搜索中。'<b>v</b>'也在搜索中使用但是不能使用正则表达式。<br>3.<b> /</b> begins the regular express<br>3.<b>/</b>开始正则表达式<br>4.<b> ^ </b>is a special character respect the start of a line.<br>4.<b> ^</b>使表示行首的元字符<br>5. the second<b> /</b> ends the regular express and indicate that the remains is action to do.<br>5. 第二个<b>/</b>在正则表达式的末尾,并表明有后续操作<br>6. <b>m</b> means move,tandco' for copy, `d' for delete
6. m 表示移动,'t' 和'co'表示复制,d为删除
7. 0 is the destination line.
7. 0 是目标行号
you can use
你可以使用
:g/regexp/t$
to filter all lines and pick the match line together and copy them to the end of the buffer or
为了过滤所有的行并全部取出匹配行到buffer中
:g/regexp/y A
to put them into a register(not eax, ebx...)
将过滤出的匹配项放入寄存器(非汇编中的eax、ebx)


Technorati Tags: ,

评论