4

I've got a program that spits out multi-line messages separated with something other than a newline. I want these messages to show in the quickfix and location lists spanning multiple lines as intended. What character can I replace the separator with to get that result? For example, setqflist([{'text': "1\r2"}]) prints 1^M2 on a single line. What character can I use to get two lines?

1 Answer 1

1

It can depend on your system. Some characters may be right on one system and not work at all on another. Between Macintosh, Windows, and Unix/Linux, there are three different types of carriage returns.

\n may work for you. You could also try them both together: \n\r (I think that's the right way, but you could also try it reversed)

Alternately, you can instruct Vim to use a particular kind of carriage return, no matter what system you are on, by playing with the fileformat (abbreviated as ff) option:

set ff=dos for example switches to the Windows formatting when it reads the file or buffer. You can re-read a file you already have open in a different format by using this command:

:e ++ff=unix

You may have to play around with it and see what works best.

For far more detail, see this page on the Vim wiki.

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.