Vim-plug: Line endings issue on Windows Subsystem for Linux

Created on 28 Jan 2019  路  3Comments  路  Source: junegunn/vim-plug

vim-plug check on line 1018 which checks if we are running a Windows version of Vim is insufficient and causes problems on the Windows Subsystem for Linux (WSL). This check returns 0 on my Ubuntu 18 (WSL) version of Vim.

I would propose changing this to allow this setting to be manually set or doing this by default all the time.

This should affect any Linux system on which the core.autocrlf setting is set to true.


$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Included patches: 1-1453
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               -ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-NQEcoP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm

  • Type:

    • [x] Bug

    • [ ] Enhancement

    • [ ] Feature Request

    • [ ] Question

  • OS:

    • [ ] All/Other

    • [ ] Linux

    • [ ] OS X

    • [x] Windows

  • Vim:

    • [x] Terminal Vim

    • [ ] GVim

    • [ ] Neovim

bug windows

Most helpful comment

I have also experienced this issue using neovim. Here's some keywords to help anyone else experiencing this issue find this: E492 Not an editor command: ^M Trailing Characters Error detected while processing.

Workaround:

As @orao mentioned, the issue is with line 1018 and assuming your vim-plug and plugins are used only inside WSL, you can work around this by simply commenting out the if and letting it be hardcoded:

  " if has('win32unix')
    let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
  " endif

This will prevent vim-plug from using crlf in the future. You'll also need to clean up plug.vim and existing plugins. First clean up plug.vim by running it through dos2unix or changing the line endings in vim, then delete the contents your plugged directory (.vim/plugged by default I believe), then run :PlugInstall to repopulate your plugins. (You could also clean up the line endings in your plugins directly, but in my case it was easier to just reinstall them, and I dont have many plugins.)

All 3 comments

I have also experienced this issue using neovim. Here's some keywords to help anyone else experiencing this issue find this: E492 Not an editor command: ^M Trailing Characters Error detected while processing.

Workaround:

As @orao mentioned, the issue is with line 1018 and assuming your vim-plug and plugins are used only inside WSL, you can work around this by simply commenting out the if and letting it be hardcoded:

  " if has('win32unix')
    let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
  " endif

This will prevent vim-plug from using crlf in the future. You'll also need to clean up plug.vim and existing plugins. First clean up plug.vim by running it through dos2unix or changing the line endings in vim, then delete the contents your plugged directory (.vim/plugged by default I believe), then run :PlugInstall to repopulate your plugins. (You could also clean up the line endings in your plugins directly, but in my case it was easier to just reinstall them, and I dont have many plugins.)

For anyone experience this issue. Try turn off auto crlf for your git.

git config --global core.autocrlf false

This error still occurs, but git config --global core.autocrlf false fixes it. WSL 2, ubuntu 20.4, bash, neovim

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bmcilw1 picture bmcilw1  路  3Comments

bearzyj picture bearzyj  路  3Comments

phongvcao picture phongvcao  路  4Comments

LandonSchropp picture LandonSchropp  路  4Comments

meain picture meain  路  3Comments