1

When I start just vi which is alias to vim:

$ which vi
alias vi='vim'
/usr/bin/vim

my ~/.vimrc is used which is great, every configuration and all plugins are being properly loaded and etc.

However if I try to run:

vim -u ~/.vimrc

or

vi -u ~/.vimrc

I get the following error:

Eror detected while processing /home/dstoev/.vimrc:
line   10:
E117: Unknown function: pathogen#infect
line   19:
E15: Invalid expression: {
line   20:
E10: \ should be followed by /, ? or &
line   21:
E10: \ should be followed by /, ? or &
line   22:
E10: \ should be followed by /, ? or &
line   23:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue

My ~/.vimrc :

"filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
set laststatus=2
syntax on
execute pathogen#infect()
" let g:indent_guides_start_level = 1
let g:indent_guides_enable_on_vim_startup = 1
" automatically start indent_guides plugin
let g:indent_guides_auto_colors = 0
"hi IndentGuidesOdd  guibg=red   ctermbg=4
"hi IndentGuidesEven guibg=green ctermbg=4
hi IndentGuidesOdd  ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ], [ 'readonly', 'absolutepath', 'modified' ] ],
      \ }
      \ }
" show full path in the status bar,plugin lightline

Running VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 4 2019 16:22:18) on 4.20.13-200.fc29.x86_64 as a normal user (with sudo capabilities/wheel group).

  • Does vim -Nu ~/.vimrc work? -N enables nocompatible (see answer by D. Ben Knoble). – Hotschke Mar 10 at 10:25
2

Your vimrc forgets to set 'nocompatible' if compatible is already set.

Typically, when vim is started and finds a vimrc, it disables compatibility.

However, such a check may not be done with the -u option. So I’d do

if &compatible
  set nocompatible
endif

At the top of your vimrc.


Diagnosis

The error traces in your snippet showed evidence of failing to interpret key features of vimscript, like autoload functions and line continuations. These are not present in vi, hence the guess about compatible.

  • The if &compatible is important! See this question and its answer, that doesn't work, if set nocompatible is used unconditional. – Ralf Mar 10 at 7:09
  • 1
    @D. Ben Knoble, this is it! Thank you! – xidiot Mar 10 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.