I want to replace all new line characters with the two literal characters '\' and 'n' in macvim under a selected area.
For example
i have selected the following lines (in .js file) :
# /messages/{id}
## GET
+ Response 200 (text/plain)
Hello World!
## DELETE
+ Response 204
Then i am applying
:'<,'>s#\n#/\n#g
that replaces into :
'# /messages/{id}/^@/^@## GET/^@+ Response 200 (text/plain)/^@/^@ Hello World!/^@/^@## DELETE/^@+ Response 204'/^@
My desired output is :
# /messages/{id}/\n/\n## GET/\n+ Response 200 (text/plain)/\n/\n Hello World!/\n/\n## DELETE/\n+ Response 204'/\n
Why there is ^@ instead of \n?
And how can i get \n?
Use \n in the search part of your substitution and \r in the replace part:
:%s#\n#/\r#g
EDIT
Oh! Do you want to replace all EOLs with literal \n?
:%s/\n/\\n
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