I remember that Macs always used to use CR despite Unix using LF and Windows using CR+LF
Your memory is from the good old times though: Mac OS X, as POSIX-compliant Unix uses the typical Unix LF
.
CR
is a relict from the "classic" Mac OS, it's not used anymore.
For example, check the manpage of unix2dos
(emphasis mine):
In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF). In Unix text files a line break is a single character: the Line Feed (LF). In Mac text files, prior to Mac OS X, a line break was single Carriage Return (CR) character. Nowadays Mac OS uses Unix style
(LF) line breaks.
An even more authoritative reference: Shell Scripting Primer: Designing Scripts for Cross-Platform Deployment
Command-line tools in Mac OS X (and other UNIX or Linux variants) use UNIX-style line endings. This means that each line in a text file ends with a newline character (character 10/0xA, often abbreviated LF).
Many older Mac applications use "Mac-styleā€¯ line endings. This means that each line in a text file ends with a carriage return character (character 13/0xD, often abbreviated CR).
Vim looks in ~/.vim because that directory is in the default list in 'runtimepath', abbreviated as 'rtp'. To tell Vim to look elsewhere, you will have to completely specify a different 'rtp' value, or edit the default using a call to substitute() for example. If you just want Vim to look in a different place for your configuration files first, don't care that it also looks in ~/.vim, and don't care that it doesn't look in your alternative after directory, the command is pretty simple:
vim --cmd 'set rtp^=alternate_dir'
See
:help --cmd
:help :set^=
Replacing .vim with your alternative directory takes a little more typing.
vim --cmd 'let &rtp = substitute(&rtp, "\.vim", "alternate", "g")'
I tried replacing ~/.vim
with another path, but I couldn't match the ~
, so I went ahead and posted what I had.
Edit
The reason I could not match the ~
in the value of 'rtp' is that when the value is obtained as the value of &rtp
rather than the output of :set rtp?
, the ~
is expanded to the full path name of the user's home directory. There is no ~
in the result.
The following works.
vim --cmd 'let &rtp = substitute(&rtp, $HOME."/\.vim", "alternate", "g")'
Best Answer
In recent versions of Vim there's a 'listchars' setting that lets you specify which characters should be used for the EOL and TAB characters, and for trailing spaces.
You could:
...to display eol chars specially without collapsing tabs (type a space character, not [,S,P,A,...).
I don't know of anything specifically about return chars in the 'listchars' setting, but I suspect you can use syntax highlighting for this. I think the default display of \r characters is to show them with SpecialKey highlighting.
So the default SpecialKey highlighting of \r characters, combined with setting 'listchars' as above, should be close to what you need.
...if you're fond of magenta.