Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Trailing Characters in Ubuntu

Tags:

vim

ubuntu

I'm trying to set up my VIMRC (gvim on Ubuntu 11.10)file which contains just 2 lines (as of now)

set ruler
set number

I keep getting this error:

line 1:
E488: Trailing characters: number^M 
line  2: 
E488: Trailing characters: ruler^M

How do I resolve this?

like image 989
Prakhar Avatar asked Feb 09 '12 07:02

Prakhar


People also ask

How do I delete a trailing character in Vim?

Every time the user issues a :w command, Vim will automatically remove all trailing whitespace before saving.

What is trailing characters in Vim?

The "trailing characters" are in your command, not your document. Vim thinks that you finished the command at Article</ , then considers h2>/gi as the third argument of the substitute command. But those characters aren't all valid for the third argument, so it gives you the error.

What does Trailing character mean?

Trailing characters are those characters which occur at the end of the string (rightmost part of the string).


2 Answers

As pointed out by the comment, it seems that you've got some \r characters from a windows configuration. To solve this use:

dos2unix <file>
like image 164
jcollado Avatar answered Oct 02 '22 20:10

jcollado


Open the vimrc file in vim (this will probably work with errors. If it doesn't then move _vimrc to myVimrc):

vim _vimrc

Then run this ex command:

:set fileformat=unix

Dos2Unix didn't work for me. I think that dos2unix only works with ANSI files.

dos2unix <file> 
like image 31
sixtyfootersdude Avatar answered Oct 02 '22 18:10

sixtyfootersdude