宏似乎没有考虑到击键.在这个特殊情况下,我想写一个注释掉一行的宏(在latex注释开头%).这是我正在使用的击键:
q+ a+ 0+ w+ i+ %+ j+ j+ j+ + q
其中a指定一个宏,进入行的开头,进入插入模式,放置百分号,退出插入模式,向下移动一行,然后结束宏.然后我像这样使用宏
@ + a
如果我有4条线就像这样
1 In This life I have learned one thing ?
2 It is pity incarnate of which I sing.
3 You have been told about the back of the crowd
4 And I repeat it, plenty loud.
Run Code Online (Sandbox Code Playgroud)
使用宏三次导致这一点
1 %%%In This life I have learned one thing ?
2 It is pity incarnate of which I sing.
3 You have been told about the back of the crowd
4 And I repeat it, plenty loud.
Run Code Online (Sandbox Code Playgroud)
当我想要的是这个
1 %In This life I have learned one thing ?
2 %It is pity incarnate of which I sing.
3 %You have been told about the back of the crowd
4 And I repeat it, plenty loud.
Run Code Online (Sandbox Code Playgroud)
更具体地说,我希望能够做30 + @+ a来评论30行.我该怎么做呢?
我会去:
:.,+30 s/^\s*/&%
Run Code Online (Sandbox Code Playgroud)
说明:
.,+30是从当前行到当前行+ 30的范围(因此跨越31行)(:help range)s是替换命令(:help :s)/ 是模式分隔符^\s*是一个pattern(:help pattern),对应于一行开头的任意数量的空格& 是插入匹配模式的替换特殊字符另一种方式:
ab©d (cursor on the c)
efgh
ijkl
Run Code Online (Sandbox Code Playgroud)
类型CTRL-V,2j,I,你好,Esc你会得到:
abhellocd
efhellogh
ijhellokl
Run Code Online (Sandbox Code Playgroud)