In the following vim macro from this article, the author gives an explanation. I understand some but not everything.
:qccwcommand<Esc>:w<Ctl-W>jj<Enter>q
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.
Q1. What is ccw
doing here? Is it something to do with cw
(change word) but I am not sure.
Q2. :w must be to write, right?.
Q3. What is <Ctrl-W>jj
doing here? The following is what :h CTRL-W_J
is about but I am not sure if I am looking into the correct help nor the meaning of the help in this context.
*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.
you're confused because
ccw
taken literally in that sequence of commands dosen't really make sense!the initial
qc
means "start macro recording in register c"then the next
cw
means change word (e.g. delete the next word and leave editor in insert mode)also notice that the final command is a
q
: this means to finish the macro recording. Macros are super useful when doing things that require a lot of repetition!!1 --> http://vim.wikia.com/wiki/Macrosthen, his explanation in the blog post contains the answer to Q2 and Q3
Q2 - yup, to save the file: "
write the file out to disk
"Q3 - the
<Ctl-W>jj<Enter>
is a sequence of Vim key commands to move to the next entry in the quickfix window from the vimgrep, as he indicates: "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.
"