I use the following Vim macro a lot (it puts the current line inside XML tags):
I<e>^[A</e>
So I saved it into my .vimrc
let @e='I<e>^[A</e>'
But it does not work.
The ^[
part means "Escape" but it is not understood as such in .vimrc
How can I save this macro, or any macro that contains "Escape" ?
Escape key adds extra bytes into the register when recording a macro.
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.
If you use Vim in a terminal, simply press alt/meta+normal_mode_key. Most terminals send an escape character followed by the normal_mode_key that you pressed, removing the need to press escape yourself.
6) actually persists macros and named buffers automatically (by default, although I haven't looked for a way of turning this behavior off). Closing a Vim session will update the ~/. viminfo file with any named buffers / macros.
Try entering the escape with <Ctrl-v><Esc>
in insert mode. See :help i_CTRL-V
in vim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With