Trailing ^M characters in .vimrc?

5,704 views
Skip to first unread message

Jonathan

unread,
Feb 27, 2010, 3:39:17 AM2/27/10
to vim_mac
Apologies if this is an obvious problem, but the solutions I've been
looking at don't seem to work.

When I load MacVim (via mvim from the terminal), the following error
messages appear:

>Error detected while processing /Users/jweed/.vimrc:
>line 2:
>E488: Trailing characters: nocompatible^M
>line 5:
>E474: Invalid argument: columns=80^M
>line 6:
>E474: Invalid argument: wrapmargin=8^M
>line 7:
>E492: Not an editor command: ^M

Based on information I've found online, this seems to be a problem
with line encodings. The only solutions I've found suggest fixing this
problem by running a substitute command: %s/\r/\r/g. I've tried this
(from inside MacVim) and it seems to work fine, but when I restart
mvim the same error occurs and my .vimrc options are not set.

Any suggestions? For reference, my .vimrc appears below, as it appears
when I open it in macvim.

Thanks, Jonathan

----
ab imgdiv ^M<div class="separator" style="clear: both; text-align:
center;" markdown="1">^M^M</div>
set nocompatible
map \ :w^M:!/Users/jweed/bin/markdown <"%" \| /Users/jweed/bin/mvim -
^M
map :w^M:!/Users/jweed/bin/markdown <"%" >"%.html"^M^M:!open
"%.html"^M^M
set columns=80
set wrapmargin=8

Maximilian Nickel

unread,
Feb 28, 2010, 9:03:57 AM2/28/10
to vim...@googlegroups.com
On Sat, Feb 27, 2010 at 9:39 AM, Jonathan <jonath...@gmail.com> wrote:
> Apologies if this is an obvious problem, but the solutions I've been
> looking at don't seem to work.
>
> When I load MacVim (via mvim from the terminal), the following error
> messages appear:
>
>>Error detected while processing /Users/jweed/.vimrc:
>>line    2:
>>E488: Trailing characters: nocompatible^M
>>line    5:
>>E474: Invalid argument: columns=80^M
>>line    6:
>>E474: Invalid argument: wrapmargin=8^M
>>line    7:
>>E492: Not an editor command: ^M
>
> Based on information I've found online, this seems to be a problem
> with line encodings. The only solutions I've found suggest fixing this
> problem by running a substitute command: %s/\r/\r/g. I've tried this
> (from inside MacVim) and it seems to work fine, but when I restart
> mvim the same error occurs and my .vimrc options are not set.
>
> Any suggestions? For reference, my .vimrc appears below, as it appears
> when I open it in macvim.
>
> Thanks, Jonathan
>

You can open that file, enter "set fileformat=mac" and write it again.
This should convert all line-endings to a Mac-friendly format.

Regards,
Max

Tony Mechelynck

unread,
Mar 1, 2010, 10:18:35 AM3/1/10
to vim_mac
On Feb 27, 9:39 am, Jonathan <jonathan.w...@gmail.com> wrote:
> Apologies if this is an obvious problem, but the solutions I've been
> looking at don't seem to work.
>
> When I load MacVim (via mvim from the terminal), the following error
> messages appear:
>
> >Error detected while processing /Users/jweed/.vimrc:
> >line    2:
> >E488: Trailing characters: nocompatible^M
> >line    5:
> >E474: Invalid argument: columns=80^M
> >line    6:
> >E474: Invalid argument: wrapmargin=8^M
> >line    7:
> >E492: Not an editor command: ^M
>
> Based on information I've found online, this seems to be a problem
> with line encodings. The only solutions I've found suggest fixing this
> problem by running a substitute command: %s/\r/\r/g. I've tried this
> (from inside MacVim) and it seems to work fine, but when I restart
> mvim the same error occurs and my .vimrc options are not set.
>
> Any suggestions? For reference, my .vimrc appears below, as it appears
> when I open it in macvim.
>
> Thanks, Jonathan
>

See :help :source-crnl

If you want to use a single vimrc on Unix-like Vim (which can only
handle LF-only ends-of-lines) and on Mac-Classic-like Vim (which can
handle either LF-only or CR-only but only if 'fileformats' [plural] is
not empty) you may have to (1) make sure that your vimrc was written
with 'fileformat' (singular) set to "unix" (use :setlocal ff=unix just
before writing it) and (2) invoke Vim with --cmd "set ffs=mac,unix" on
the command-line.

See also
:help 'fileformat'
:help 'fileformats'
:help --cmd


Best regards,
Tony.
--
On account of being a democracy and run by the people, we are the only
nation in the world that has to keep a government four years, no
matter
what it does.
-- Will Rogers

Reply all
Reply to author
Forward
0 new messages