Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remap the vim record macro key from 'q' to 'Q'?

Tags:

vim

Sometimes I accidentally enter vim's record macro mode by pressing 'q' (which I usually get out of by pressing q two more times.)

What are the commands to change the keybinding to start recording a macro from 'q' to 'Q'?

I can stop 'q' from doing anything by setting

nnoremap q <Nop>

but I'm not sure how to get 'Q' to be the record macro shortcut.

like image 971
k107 Avatar asked Jun 08 '12 21:06

k107


People also ask

Where does Vim store macros?

As you yank , delete , or create macros in vim, it automatically stores text into these registers. When you hit p paste it's simply pasting in the default register. You can also paste in any other register by hitting "qp where q is the register that you want to paste in.

What is recording @U in Vim?

Recording is a really useful feature of Vim. It records everything you type. You can then replay it simply by typing @ <letter> . Record search, movement, replacement...

How do I record a macro in Vim?

To record a macro and save it to a register, type the key q followed by a letter from a to z that represents the register to save the macro, followed by all commands you want to record, and then type the key q again to stop the recording.


1 Answers

You can remap Q to quit and q to no command in two command lines Like this:

nnoremap Q q
nnoremap q <Nop>
like image 76
Ned Batchelder Avatar answered Oct 31 '22 11:10

Ned Batchelder