How to write and / or create a vim macro that includes the character "q" in normal mode?

It is well known that q used to start recording, as well as to stop recording a macro.

Unfortunately, I'm trying to write a sequence of commands that includes the q: command, and the macro (naturally) stops writing to q .

Is there a way to write a sequence of commands that includes q in typical mode?

Update: I tried reassigning q to something else and matching another letter with q , but this seems to violate the q functionality for the actual command I'm trying to write.

+4
source share
2 answers

You can do : Ctrl + f to open the command history window without stopping the recording.

+4
source

Good thing you got the accepted answer, I just mentioned another trick for writing a macro, so you can have q: in the macro:

You can press :ctrl-f , or if you really love q: you can:

eg:

 let @q='5j5kq:<cv><up><cv><enter>j' 

5j5k does nothing, for example.

200@q will execute the last command for the next 200 lines. If your last command passes some arguments, for example, the current line number or the current line (text) to the function. he will work too.

If you want to edit the command line in a macro, you need to press the key sequence before <cv><enter> .

for <cv><up><cv><enter> , you really need to enter such text, not plain text.

but, from my point of view, these tricks are not needed for ordinary tasks.

+3
source

All Articles