Inside of a variable, a newline is encoded as ^@ which represents a null byte.

In the vim Ex command line it is possible to issue something like substitute(var, '^@', '\\n', 'g'), this produces \n instead which can be passed to e.g. bash cleanly.

However, putting this into a function inside my vimrc breaks horribly with a missing quote E115, so I have to escape it somehow, but I cannot figure out how.


I've figured out that '\n' can be used in substitute() to refer to the null byte which is used internally to represent an end of line. This solved my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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