I got some output code that has random backslashes, followed by a new line. For example:

( 1-z+z^11-z^12+z^22-z^23+z^33-z^34+z^37-z^38+z^40-z^41+z^43-

I want to remove all the backslashes and newlines so that it's all on one continuous line. I was thinking the way to do this would be to move the cursor to before each backslash occurrence, and then hit delete twice. Is there a way to automate this on Vim so it searches the entire document and does it for all cases? Thanks!

1 Answer 1


You can substitute nothing for backslash-followed-by-newline throughout your buffer:


See :help :substitute.

  • When I try using this, it says that there is no \\\n
    – Zonova
    Commented Jan 24, 2017 at 15:14
  • Are you using Vi as opposed to Vim? If not, are you opening the file with the correct encoding?
    – jjaderberg
    Commented Jan 24, 2017 at 20:36
  • If you have trailing spaces use %s/\\\s*\n//g
    – laktak
    Commented Jan 25, 2017 at 20:32

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.