As I spent more time playing with VIM, I ran into this very simple issue but took a while to find a solution.
Description
If you want to customize your VIM a bit more, you just have to create a .vimrc in the root. Even if you create/edit the .vimrc in VIM, better than Notepad right? NOT! Apparently, by default, VIM doesn’t set the file format for you. So it leaves a “trailing ^M” and VIM doesn’t like that…
Symptoms
- Windows: it shows a blank screen and has “Hit enter to type command” or something like that before VIM starts. It doesn’t show any errors.
- Ubuntu (see screenshot): it actually displays the following errors: “Invalid argument on^M” OR “Trailing characters ^M” OR “Not an editor command: ^M”
To fix this, it’s actually pretty easy.
While in VIM and in command mode type:
:set fileformat=unix
Of course the setting depends on your system, 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 Windows and set it to dos commands… set it to dos. Now you’re safe to edit .vimrc, when you :wq and vim again, the blank black screen (on Windows), and “Invalid editor commands” should go away.
