3

Let's say I record a macro n that generates the following text:

1
2

When I ask for the content with "np it outputs:

i1^M2^M^[

So I append in .vimrc file:

let @n = 'i1^M2^M^['

if I save .vimrc and then I call it with @n in a new file, it outputs the string above literally.....

How should I represent the newline key in configuration file?

3
  • Macros are often a poor substitute for a mapping when you want to save them. Did you type ^ then M, or <C-v><C-m>?
    – D. Ben Knoble
    Commented Feb 2, 2020 at 1:53
  • 1
    Did you use "np to paste the escaped characters ^M and ^[ into the vim script?
    – Arnie97
    Commented Feb 2, 2020 at 3:31
  • 1
    @D.BenKnoble I typed ^ then M, the second way doest not work either.
    – sebelk
    Commented Feb 2, 2020 at 12:05

1 Answer 1

3

The solution I've found is:

let @n = "i1\n2\n\e"

however the following does not work:

let @n = 'i1\n2\n\e'

1
  • 3
    the following does not work Please, read :h expr-" and :h expr-'
    – Matt
    Commented Feb 2, 2020 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.