首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ccw在Vim宏中的作用是什么

ccw在Vim宏中的作用是什么
EN

Stack Overflow用户
提问于 2014-01-05 13:24:36
回答 1查看 129关注 0票数 1

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

代码语言:javascript
复制
: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的内容,但我不确定我是否在查看正确的帮助,也不确定该帮助在此上下文中的含义。

代码语言:javascript
复制
                                        *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.
EN

回答 1

Stack Overflow用户

发布于 2014-01-05 17:37:55

你会感到困惑,因为从字面上看,在命令序列中使用ccw是没有意义的!

初始qc的意思是“在寄存器c中开始宏记录”

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

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

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

代码语言:javascript
复制
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 - yup,保存文件:"write the file out to disk

Q3 - <Ctl-W>jj<Enter>是一系列Vim key命令,用于从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.

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20930426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档