Viewing \n and \r characters in Vim?
Asked Answered
H

1

8

Is there a way to make \n or \r characters visible in vim? (I want to be able to see if the csv file I am looking at uses just \n or \r and \n at the end of lines.

Hydrotherapeutics answered 15/5, 2012 at 14:34 Comment(3)
:set invlist seems to do the trick, but is the $ an \n or a \r\n?Hydrotherapeutics
Vim usually remarks on this when you load the file, doesn't it? (eg, will say [DOS] with the file name if the line endings are \r\n).Abscond
I opened a file that I wrote in Windows and another that I wrote in Ubuntu with Vim, and used :set invlist on both of them. I expect that the end of line characters are different for both files, but Vim flagged them up as $ in both. So I think you want a different command. Don't know what it is, though!Lund
H
8
:setl fileformat?

dos means CR-LF (consistently; if only some lines contain both, it'll be listed as unix, and you'll see ^M characters at the end of those lines), unix means LF; mac means only CR newlines.

Horribly answered 15/5, 2012 at 15:23 Comment(2)
hmm when I ran that command it said fileformat=dos so that must mean CR followed by LF (\r\n) ?Hydrotherapeutics
@leeand00: Correct. If you deal with different fileformats regularly, it may make sense to add %{&l:fileformat} to a custom statusline.Horribly

© 2022 - 2024 — McMap. All rights reserved.