I'm trying to save a vim macro that includes the backspace character to my vimrc file. The idea of this macro is to add a documentation segment in a js file. So if I have the following function:
function foo() {
}
I'll put the cursor on the function line, run the macro and it will create:
function foo() {
/*
| <- Cursor ends up here in insert mode.
*/
}
When I created the macro I got the following register:
o/*^M<80>kb<80>kb<80>kb*/<80>ku^M<80>kb<80>kb<80>kb
(<80> is a single character)
I tried adding this as a let command:
let a='o/*^M<80>kb<80>kb<80>kb*/<80>ku^M<80>kb<80>kb<80>kb'
but when I run it it just prints out:
function foo() {
/*^M<80>kb<80>kb<80>kb*/<ESC>O<80>kb<80>kb<80>kb
}
Is there some escaping that I'm missing? Maybe there's a different and better way to do this?
Those <80>kb are the internal key code for backspace. Replace each with \<BS> (and write ^M as \<CR>), and put the entire macro string in double quotes, and you should be good to go.
Also, to assign to register a, you need to use @a.
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