Can't convert vim macro text to normal characters
I'm trying to save a vim macro that I wrote into my .vimrc
file. I successfully recorded the macro into register s
, the contents of which display as:
.,.s/S:/\&AHOMW€kbW€kbE/:.,.s/\\/\//g'€kb0
I next put an instruction in my .vimrc
file as follows:
let @s=':.,.s/S:/\&AHOMW€kbW€kbE/:.,.s/\\/\//g'€kb0'
When I start a new vim session, as vim is starting up it complains about the "let" command being an invalid expression. In my searching I've come across something call a "normal" command that appears to be able to convert an expression like the one above into normal text. I've tried the "normal" command and an "exe ""normal ... "" " command, but neither gives me back a translated version of my macro text in plain characters.
What is the proper approach to being able to define a "let" instruction with plain text macro instructions derived from the above type of example which is how the macro first gets saved in the s register during an active editing session?
Thanks much in advance.
The problem is that your macro contains a single quote, and you're trying to quote the entire string with single quotes without escaping the single quote in the macro. Vim has a slightly unusual way of escaping a single quote inside single quote strings, and that is to just add another single quote. For example:
let @s=':.,.s/S:/\&AHOMW€kbW€kbE/:.,.s/\\/\//g''€kb0'