ccw在Vim宏中做了什么

时间:2014-01-05 05:24:36

标签: vim vim-macros

在下面的vim宏from this article中,作者给出了解释。我理解一些但不是一切。

:qccwcommand<Esc>:w<Ctl-W>jj<Enter>q

此宏(包括记录开始/停止,如果您想知道)将把当前的'path_to_command'字改为'command',将文件写入磁盘,将窗口分割更改为grep搜索结果,移动在结果中向下一行并导航到该结果的位置。

Q1。 ccw在这做什么?是否与cw(更改单词)有关,但我不确定。

Q2。 :w必须要写,对吗?

Q3。 <Ctrl-W>jj在这做什么?以下是:h CTRL-W_J的内容,但我不确定在这种情况下我是否正在寻找正确的帮助或帮助的意义。

                                        *CTRL-W_J*
CTRL-W J    Move the current window to be at the very bottom, using the
    full width of the screen.  This works like closing the current
    window and then creating another one with ":botright split",
    except that the current window contents is used for the new
    window.

1 个答案:

答案 0 :(得分:5)

你很困惑,因为ccw字面意义上的命令序列实际上并不合理!

初始qc表示“在寄存器c中开始宏录制”

然后下一个cw表示更改单词(例如删除下一个单词并在插入模式下保留编辑器)

还注意到最后一个命令是q:这意味着完成宏录制。在做需要大量重复的事情时,宏非常有用!! 1 - &gt; http://vim.wikia.com/wiki/Macros


然后,他在博客文章中的解释包含Q2和Q3的答案

This macro (which includes the record start / stop, if you’re wondering)
will change the current ‘path_to_command’ word to ‘command’, write the file
out to disk, change window splits to the grep search results, move down one
line in the results and navigate to that result’s location. I ran the macro
by hitting @c and then verifying the line selected was one that I wanted to
change. For a few instances where I did not want to change the line, I
manually navigated to the next search result and then re-ran the @c macro.

Q2 - 是的,保存文件:“write the file out to disk

Q3 - <Ctl-W>jj<Enter>是一系列Vim键命令,用于从vimgrep移动到quickfix窗口中的下一个条目,因为他指出:“write the file out to disk, change window splits to the grep search results, move down one line in the results and navigate to that result’s location.