[vim/vim] E492: Not an editor command: ^M on Linux subsystem (#6156)

1,259 views
Skip to first unread message

Jan

unread,
May 29, 2020, 6:54:52 AM5/29/20
to vim/vim, Subscribed

I installed Vim on Ubuntu via Linux Subsystem on Windows 10, so I can use it for work. I changed the home directory to the Windows user directory and symlinked the Ubuntu home to it. I use VimPlug and installed several plugins, which works well. But now I am getting a lot of errors including the on in the title.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Jan

unread,
May 29, 2020, 7:18:56 AM5/29/20
to vim/vim, Subscribed

Error detected while processing /mnt/c/Users/user/.vim/plugged/c-support/ftdetect/template.vim:
line   18:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-go/ftdetect/gofiletype.vim:
line    2:
E492: Not an editor command: ^M
line    4:
E15: Invalid expression: &cpo^M
line    5:
E488: Trailing characters: cpo&vim^M
line    6:
E492: Not an editor command: ^M
line   11:
E492: Not an editor command: ^M
line   20:
E492: Not an editor command: ^M
line   21:
E488: Trailing characters
line   35:
E492: Not an editor command: ^M
line   37:
E121: Undefined variable: s:cpo_save
E15: Invalid expression: s:cpo_save^M
line   38:
E488: Trailing characters
line   39:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-easy-align/plugin/easy_align.vim:
line   23:
E492: Not an editor command: ^M
line   24:
E15: Invalid expression: exists("g:loaded_easy_align_plugin")^M
line  143:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-github-dashboard/plugin/github_dashboard.vim:
line    1:
E15: Invalid expression: !has('ruby')^M
line   12:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.vim/plugged/c-support/plugin/c.vim:
line   34:
E492: Not an editor command: ^M
line   38:
E492: Not an editor command: ^M
line   40:
E15: Invalid expression: v:version < 700^M
line 3050:
E170: Missing :endfor
Error detected while processing /mnt/c/Users/user/.vim/plugged/YCM-Generator/plugin/ycm-generator.vim:
line    1:
E492: Not an editor command: ^M
line    2:
E15: Invalid expression: expand("<sfile>:p:h:h") . "/config_gen.py"^M
line    3:
E492: Not an editor command: ^M
line    6:
E492: Not an editor command: ^M
line    7:
E488: Trailing characters
line   23:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-go/plugin/go.vim:
line    2:
E15: Invalid expression: exists("g:go_loaded_install")^M
line  311:
E488: Trailing characters
line  314:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.fzf/plugin/fzf.vim:
line   23:
E492: Not an editor command: ^M
line   24:
E15: Invalid expression: exists('g:loaded_fzf')^M
line  542:
E488: Trailing characters
line  953:
E488: Trailing characters
line  954:
E171: Missing :endif
error detected while processing /mnt/c/Users/user/.vim/plugged/vim-rainbow/plugin/rainbow.vim:
line    6:
E492: Not an editor command: ^M
line   26:
E15: Invalid expression: ^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M ]^M
E15: Invalid expression: exists('g:rainbow_guifgs')? g:rainbow_guifgs : [^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M ]^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/c-support/ftdetect/template.vim:
line   18:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-go/ftdetect/gofiletype.vim:
line    2:
E492: Not an editor command: ^M
line    4:
E15: Invalid expression: &cpo^M
line    5:
E488: Trailing characters: cpo&vim^M
line    6:
E492: Not an editor command: ^M
line   11:
E492: Not an editor command: ^M
line   20:
E492: Not an editor command: ^M
line   21:
E488: Trailing characters
line   35:
E492: Not an editor command: ^M
line   37:
E121: Undefined variable: s:cpo_save
E15: Invalid expression: s:cpo_save^M
line   38:
E488: Trailing characters
line   39:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-easy-align/plugin/easy_align.vim:
line   23:
E492: Not an editor command: ^M
line   24:
E15: Invalid expression: exists("g:loaded_easy_align_plugin")^M
line  143:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-github-dashboard/plugin/github_dashboard.vim:
line    1:
E15: Invalid expression: !has('ruby')^M
line   12:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.vim/plugged/c-support/plugin/c.vim:
line   34:
E492: Not an editor command: ^M
line   38:
E492: Not an editor command: ^M
line   40:
E15: Invalid expression: v:version < 700^M
line 3050:
E170: Missing :endfor
Error detected while processing /mnt/c/Users/user/.vim/plugged/YCM-Generator/plugin/ycm-generator.vim:
line    1:
E492: Not an editor command: ^M
line    2:
E15: Invalid expression: expand("<sfile>:p:h:h") . "/config_gen.py"^M
line    3:
E492: Not an editor command: ^M
line    6:
E492: Not an editor command: ^M
line    7:
E488: Trailing characters
line   23:
E492: Not an editor command: ^M
Error detected while processing /mnt/c/Users/user/.vim/plugged/vim-go/plugin/go.vim:
line    2:
E15: Invalid expression: exists("g:go_loaded_install")^M
line  311:
E488: Trailing characters
line  314:
E171: Missing :endif
Error detected while processing /mnt/c/Users/user/.fzf/plugin/fzf.vim:
line   23:
E492: Not an editor command: ^M
line   24:
E15: Invalid expression: exists('g:loaded_fzf')^M
line  542:
E488: Trailing characters
line  953:
E488: Trailing characters
line  954:
E171: Missing :endif
error detected while processing /mnt/c/Users/user/.vim/plugged/vim-rainbow/plugin/rainbow.vim:
line    6:
E492: Not an editor command: ^M
line   26:
E15: Invalid expression: ^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M ]^M
E15: Invalid expression: exists('g:rainbow_guifgs')? g:rainbow_guifgs : [^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M '#458588',^M '#b16286',^M '#cc241d',^M '#d65d0e',^M ]^M

K.Takata

unread,
May 29, 2020, 7:38:45 AM5/29/20
to vim/vim, Subscribed

You must save your .vimrc in unix fileformat (LF line ending).

Please ask user questions on the vim_use mailinglist or use vi.stackexchange.com. This here is a bug tracker for problems with Vim. We cannot provide individual help here. Closing.

K.Takata

unread,
May 29, 2020, 7:38:49 AM5/29/20
to vim/vim, Subscribed

Closed #6156.

Tony Mechelynck

unread,
May 29, 2020, 10:09:24 AM5/29/20
to vim/vim, Subscribed

Apparently you got the "Windows" set of runtime files (with <CR><NL> ends-of-lines) and Vim believes it's running on a "Unix-like" OS:

For systems with a Dos-like <EOL> (<CR><NL>), when reading files that
are ":source"ed and for vimrc files, automatic <EOL> detection may be
done:

  • When 'fileformats' is empty, there is no automatic detection. Dos
    format will be used.
  • When 'fileformats' is set to one or more names, automatic detection
    is done. This is based on the first <NL> in the file: If there is a
    <CR> in front of it, Dos format is used, otherwise Unix format is
    used.

All this, however, happens only in Vim "for Windows". OTOH, runtime files "for Unix" (with only <NL> ends-of-lines) can be used by any Vim. So not only your vimrc, but any script to be sourced, must have a <NL> without <CR> at the end of every line.

Jan

unread,
May 29, 2020, 11:43:00 AM5/29/20
to vim/vim, Subscribed

Well, this Vim is installed on the Ubuntu subsystem for Linux and it probably pulls the Windows version of the plugins, because all data from the internet downloaded by Windows and then handed over to the subsystem. Is this possible?

I would like to use Vim on my PC for work. On Windows itself I have a few issues with plugins and if I run it on the subsystem, this happens. Bottom line for me is that Vim on Windows is horrible. I have no issues on my personal Linux machine at all.

How can I solve this now? I already tried to get rid of the ^M terminators following the guide on Vim‘s website. None of them work.

Christian Brabandt

unread,
May 29, 2020, 4:44:58 PM5/29/20
to vim/vim, Subscribed

you can use :w ++ff=unix to convert the files. Or use a tool like dos2unix or what it is called.

Having said that, I am using my vim dotfiles on unix and windows for15 years or longer and have always used unix line endings. No problems whatsoever. But please ask usage questions either at the vim_use mailinglist or at vi.stackexchange.com

Jan

unread,
May 29, 2020, 6:10:25 PM5/29/20
to vim/vim, Subscribed

I think I already tried that without success. Will try again though. On Windows I also don’t have this problem. I think it is due to the Windows subsystem, which is a Linux installed from the Microsoft store.

Edmartt

unread,
Oct 17, 2021, 3:29:09 PM10/17/21
to vim/vim, Subscribed

you can use :w ++ff=unix to convert the files. Or use a tool like dos2unix or what it is called.

Having said that, I am using my vim dotfiles on unix and windows for15 years or longer and have always used unix line endings. No problems whatsoever. But please ask usage questions either at the vim_use mailinglist or at vi.stackexchange.com

This answer solved the issue for me


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Michael Yang

unread,
Dec 26, 2021, 4:09:12 AM12/26/21
to vim/vim, Subscribed

In my case I accidentally had core.autocrlf set to true, and since plugged uses git internally, it caused all the files to be checked out with CRLF line endings.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1001134641@github.com>

thicckWire

unread,
Jul 16, 2022, 10:13:25 AM7/16/22
to vim/vim, Subscribed

In my case I accidentally had core.autocrlf set to true, and since plugged uses git internally, it caused all the files to be checked out with CRLF line endings.

for me setting core.autocrlf to false did the trick


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1186194793@github.com>

Nayden Gochev

unread,
Sep 17, 2022, 7:56:02 AM9/17/22
to vim/vim, Subscribed

I can confirm

git config --global core.autocrlf false

and reinstall spacevim

curl -sLf https://spacevim.org/install.sh | bash

works on WSL.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1250057830@github.com>

Yassa Alkis

unread,
Feb 28, 2023, 4:17:12 PM2/28/23
to vim/vim, Subscribed

I'm pretty sure that u r aware of the problem from the replies above, and those are the steps that worked for me and I'm leaving them here just in case someone else had the same issue, I'm using WSL & neovim...

  • clearing plugged dir

  • adding those couple of lines to .vimrc will make sure that any .vim file is converted to Unix

autocmd FileType vim setlocal fileformat=unix
set fileformat=unix

  • after sourcing ur .vimrc file, try to re "PlugInstall" ur plugins and all will be set.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1448927830@github.com>

Tony Mechelynck

unread,
Feb 28, 2023, 9:30:22 PM2/28/23
to vim/vim, Subscribed

To convert a file from "Windows" fileformat to "Unix" fileformat (and remove any end-of-line ^M):

  1. :e ++ff=dos " or :new instead of :e to open in a new window
    -- This will accept both and alone as a valid end-of-line
  2. :w ++ff=unix
    -- This will write the file with (without ) on all lines
  3. Repeat as needed for other files.

Best regards,
Tony.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1449238964@github.com>

Tony Mechelynck

unread,
Feb 28, 2023, 9:34:35 PM2/28/23
to vim/vim, Subscribed

Oops...

:e ++ff=dos foobar.vim " or :new for new window
" This will accept both <CR><NL> or <NL> alone for end-of-line
:w ++ff=unix
" This will write the current file with <NL> alone on all lines

Best regards,
Tony.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6156/1449241681@github.com>

Reply all
Reply to author
Forward
0 new messages