提供了我们全文选择,然后再在选中的行运行宏的办法, normal 是个很有用的东西,其意义就是在command中运行一些norm model下的操作, 提供了我们很多组合操作的可能,拓展了使用vim的维度, 比如
:g/\/\// norm dd可以删除所有的注释代码行。
It’s occasionally handy to be able to run a macro that you’ve got ready on aspecific subset of lines of the file, or perhaps just for every line.Fortunately, there’s a way to do this, too.
Using the :normal
command, you’re able to run macros from the ex command line:
:normal @a
All it takes is prefixing this with any sort of range definition to allowyou to run a macro on any set of lines that you’re able to define.
Run the macro on each line of the whole buffer:
:% normal @a
Between lines 10 and 20:
:10,20 normal @a
On the lines in the current visual selection:
:'<,'> normal @a
On the lines containing the pattern vim:
:g/vim/ normal @a
When you get confident using this, :norm
is a nice abbreviation to use.