Menu

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

This post is a preservation of the now inactive: https://nlknguyen.com/2016/06/03/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: