skip to Main Content

I’m running Ubuntu 20.04 on VMBox and am trying to get the most out of Vim. So I as following this guide
https://techinscribed.com/how-to-set-up-vim-as-an-ide-for-react-and-typescript-in-2020/
to install different plugins, starting with gruvbox. Unfortunately, neither gruvbox nor any other plugins worked, even though I followed the guide to the letter.
So here’s my .vimrc file in my home folder:

call plug#begin()
" This is where we will add plugins to install

Plug 'morhetz/gruvbox'

call plug#end()

colorscheme gruvbox

And here are the error messages:

Error detected while processing /home/marcel/.vim/plugged/gruvbox/colors/gruvbox.vim:
line    8:
E492: Not an editor command: ^M
line   11:
E492: Not an editor command: ^M
line   12:
E15: Invalid expression: version > 580^M
line 1419:
E171: Missing :endif
Press ENTER or type command to continue

Similar errors happen with any other plugin… I already tried a different color scheme and also the NERDtree. Is this a known issue? How can I alleviate the problem?

2

Answers


  1. It looks to me like it’s just an issue with the line endings. Unix uses n (or 0xA) for a newline character. Windows uses a combination of two characters: r n. The hex for a r is 0xD. ^M happens to be the way vim displays 0xD (0x0D = 13, M is the 13th letter in the English alphabet).

    You can remove all the ^M characters by running the following:

    :%s/^M//g

    Once you do that to your gruvbox.vim, I would bet that the error goes away.

    Login or Signup to reply.
  2. While Vim can perfectly edit files with Windows line endings (rn, see the other answer), it is picky about its runtime files which must have Unix line endings (n).

    The problem, here, is thus that the runtime files you get via your plugin manager have Windows line endings instead of the expected Unix line endings.

    Now, your plugin manager uses Git to retrieve those runtime files and that is where the line endings are most likely to be changed. If that’s the case, here is a guide for configuring line endings in Git.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search