I have a .gvimrc file created to configure MacVim. I'm using Plug for package management.

My .gvimrc looks as follows:

call plug#begin()

Plug 'tpope/vim-sensible' " sensible defaults
Plug 'joshdick/onedark.vim'
Plug 'sheerun/vim-polyglot' " syntax highlight
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'airblade/vim-gitgutter'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim' " fuzzy search
Plug 'w0rp/ale' " linting
Plug 'itmammoth/run-rspec.vim'
Plug 'tpope/vim-rails'
Plug 'itchyny/lightline.vim' 
Plug 'terryma/vim-multiple-cursors' " cmd + d
Plug 'tpope/vim-fugitive'
Plug 'slim-template/vim-slim'
Plug 'scrooloose/nerdcommenter'
Plug 'sgur/vim-editorconfig'
Plug 'tpope/vim-endwise'
Plug 'ervandew/supertab'

call plug#end()

"""""""""""""
" Settings
"

syntax on
colorscheme onedark

" Font settings
set guifont=Monaco:h13
set linespace=2

set number " display line numbers

set cursorcolumn " display vertical cursor line
set cursorline " display horizontal cursor line

" More natural split direction
set splitright

" Disable scrolls
set guioptions=

" Needed by nerdcommenter
filetype plugin on

" NERDTree options
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1

""""""""""""""
" Key bindings

" Spec runner
map <Leader>t :RunSpec<CR>
map <Leader>tl :RunSpecLine<CR>

" NERDtree
map <Leader>nt :NERDTreeToggle<CR>
map <D-\> :NERDTreeToggle<CR>

" Fuzzy search (FZF)
macmenu File.Print key=<nop>
map <Leader>p :FZF<CR>
nmap <A-p> :FZF<CR>
map <D-p> :FZF<CR>

And the thing is - i need to run PlugInstall after each editor open as running :FZF without it throws Not an editor command: FZF. Running PlugInstall fixes it till i close the editor. This issue applies only to fzf, no any other plugin behaves like that.

edit: it applies to run-rspec as well

  • When you run :PlugInstall what does the buffer shows? Does the repo gets cloned again each time? Have you looked at your ~/.vim and ~/.vim/plugged directories to see if there is no problem with the permissions? Did you check that the fzf plugin directory exists before you start vim? Did you check that it stills exists after you quit vim? Did you check that you don't have something in your .vimrc which is sourced before .gvimrc and which might create a conflict? – statox Dec 7 at 14:38
  • Also I just noticed that you don't specify a directory for plug#begin(). If you read the README you'll see that you are supposed to give a parameter to this function and I'm not sure the behavior is defined without this argument. Edit Actually this should not be a problem but you might still want to check that you don't get an error message. – statox Dec 7 at 14:40
  • 2
    please try with a .vimrc instead. – Christian Brabandt Dec 7 at 14:58
  • What does your vimrc look like? Is it empy? – Hotschke Dec 7 at 16:53
  • 1
    Please read vimhelp.appspot.com/starting.txt.html#load-plugins: In step (4) basically :runtime! plugin/**/*.vim happens which is before your gvimrc is sourced (step (8)) and rtp has been changed by vim-plug. You can remove the error by appending to your gvimrc runtime! plugin/**/*.vim. However, I recommend to use vimrc and stick to the given source order by vim itself. – Hotschke Dec 7 at 17:03

Not sure if this is a good idea -- I think it is better to find out root cause of the problem.

Anyway to run a command after vim has started you can use autocommands:

autocmd VimEnter * PlugInstall

I don't know if PlugInstall is a command or a function. If it is a function then you should use call PlugInstall()

I would also suggest to move all your settings to .vimrc instead of .gvimrc. At least everything that is non-gui related, like all plugs and sets.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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