Name Mon Lu

Love jQuery/CSS

Blog about Webdev

Twitter supawaza

RSS Twitter Flickr

What I am up to:


Posts Tagged ‘vimrc’

As I spent more time play­ing with VIM, I ran into this very sim­ple issue but took a while to find a solution.

Description

If you want to cus­tomize your VIM a bit more, you just have to cre­ate a .vimrc in the root. Even if you create/edit the .vimrc in VIM, bet­ter than Notepad right? NOT! Appar­ently, by default, VIM doesn’t set the file for­mat for you. So it leaves a “trail­ing ^M” and VIM doesn’t like that…

Symptoms

  • Win­dows: it shows a blank screen and has “Hit enter to type com­mand” or some­thing like that before VIM starts. It doesn’t show any errors.
  • Ubuntu (see screen­shot): it actu­ally dis­plays the fol­low­ing errors: “Invalid argu­ment on^M” OR “Trail­ing char­ac­ters ^M” OR “Not an edi­tor com­mand: ^M”

To fix this, it’s actu­ally pretty easy.

While in VIM and in com­mand mode type:

:set fileformat=unix

Of course the set­ting depends on your sys­tem, if you’re on Mac, set it to fileformat=mac. I set mine to unix because I use Git Bash and set it to use unix style, so if you are on Win­dows and set it to dos com­mands… set it to dos. Now you’re safe to edit .vimrc, when you :wq and vim again, the blank black screen (on Win­dows), and “Invalid edi­tor com­mands” should go away.