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.

leeand00
  • 25,510
  • 39
  • 140
  • 297
  • :set invlist seems to do the trick, but is the $ an \n or a \r\n? – leeand00 May 15 '12 at 14:36
  • 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`). – CodeClown42 May 15 '12 at 14:38
  • 1
    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! – DenverCoder8 May 15 '12 at 15:20

1 Answers1

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • 1
    hmm when I ran that command it said `fileformat=dos` so that must mean CR followed by LF (\r\n) ? – leeand00 May 15 '12 at 15:33
  • @leeand00: Correct. If you deal with different fileformats regularly, it may make sense to add `%{&l:fileformat}` to a custom `statusline`. – Ingo Karkat May 15 '12 at 16:12