Vim Tip: Fix plugin loading error “Not an editor command: ^M”

One of the most annoying errors you probably already encountered  with Vim terminal (not GVim) on Windows when you use Vim plugins that were obtained through Git (via plugin manager like Vundle, Pathogen, etc.) is this kind of error message:

E492: Not an editor command: ^M
line    9:
E182: Invalid command name
line   10:
E492: Not an editor command: ^M
line   12:
E182: Invalid command name
line   13:
E492: Not an editor command: ^M
line   15:
E182: Invalid command name
line   16:
E492: Not an editor command: ^M
line   18:
E182: Invalid command name

This error is reported and asked so many times on StackOverflow and GitHub, and the answers provided are mostly about removing the special character or setting file format to “unix”. However, that wouldn’t solve the problem.

It took me a very long time (I gave up many times) to finally find out the solution through this GitHub issue on Vundle. It wasn’t something many people would expect. Turned out Git’s default setting to deal with line endings is not sufficient.

All you need to do is to config your Git correctly before cloning Vim plugins:

$ git config --global core.autocrlf input

That’s it. Now you can install Vim plugins like normal.

For more information about the above Git setting, see here.

Vim Paper Color Theme

I started using Linux and Vim last Summer, and one of the first things I did in Vim, like I would do in any code editor, was to find a decent color scheme. I was surprised by how useful and colorful the terminal could be. Coming from Windows background, I realized how much I missed out. At first I was happy with the themes I found, but as I worked with less mainstream languages, most of the themes don’t work well enough. Or, some work on these languages but not on the others, so I had to switch theme based on the language I was programming, and it quickly became annoying. So, I decided to create my own color scheme.

https://github.com/NLKNguyen/papercolor-theme

Ruby

Read more