[英]How come this vim macro doesn't work?
I've got a file that looks roughly like the following: 我有一个大致如下所示的文件:
field :t, :type => String, :as => :timestamp
field :b, :type => String, :as => :test
index({ :t => 1 })
index({ :b => 1 })
I put my cursor on line 4, and record the following macro: 我将光标放在第4行,并记录以下宏:
/: <CR>
viwyma?field : ctrl-r
0, <CR>
$F:lviwy`aviwpj^ /:
<CR>
viwyma?field: ctrl-r
0, <CR>
$ F:lviwy`aviwpj ^
So search for a colon, go there, select the whole word ( t
in this case), create a mark on a
, search backwards for field followed by a colon, the word in register 0 ( t
), then a comma. 因此,搜索一个冒号,然后转到那里,选择整个单词(在这种情况下为
t
),在a
上创建一个标记,向后搜索字段,后跟一个冒号,寄存器0( t
)中的单词,然后是逗号。 Go to the end of the line, go one character to the left, select the whole word, yank it, go back to the a
mark, select the whole word, paste what I just yanked ( timestamp
), then go to the next line and to the first non-whitespace character (so I can run the macro again right away). 转到该行的末尾,向左移动一个字符,选择整个单词,将其拉出,返回到
a
标记,选择整个单词,粘贴我刚拉过的内容( timestamp
),然后转到下一行以及第一个非空白字符(因此我可以立即再次运行宏)。
After that, line 4 is what I expect, index({ :timestamp => 1 })
Then, I try running the macro again, and line 5 becomes index({ :: => 1 })
之后,第4行就是我所期望的
index({ :timestamp => 1 })
然后,我尝试再次运行宏,第5行成为index({ :: => 1 })
Thanks! 谢谢!
I found the problem. 我发现了问题。 I had installed vim-hardtime to make movement slower.
我安装了vim-hardtime,以使移动速度变慢。 I had assumed it would be disabled for macros but it turns out that's not the case.
我以为它将对宏禁用,但事实并非如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.