Why won't vim recognise a plugin command in the vimrc, but it will recognise it when running?
Asked Answered
P

3

5

I've installed the vim-gitgutter plugin with pathogen. I can type :GitGutterLineHighlightsEnable from inside vim and line highlights are turned on, great.

But I want line highlights to be automatically enabled at startup, so I added the command to my ~/.vimrc. However when I start vim, I get "E492: Not an editor command: GitGutterLineHighlightsEnable". Once vim has started up, I can run the command.

My vimrc looks like this:

execute pathogen#infect()
colorscheme railscasts

  .. snip tabs and colors etc ..

GitGutterLineHighlightsEnable
hi GitGutterAddLine guibg=#222F22
hi GitGutterChangeLine guibg=#222239
hi GitGutterDeleteLine guibg=#2F2222
Pansir answered 24/1, 2014 at 1:4 Comment(0)
D
6

As you determined yourself, plugins are processed after the .vimrc.

What you can do if you don't like using a VimEnter autocmd, is put a file in your ~/.vim/after/plugin directory for any commands that should run after plugins are loaded.

Durant answered 24/1, 2014 at 5:3 Comment(0)
P
10

Figured it out.

.vimrc is executed before plugins are loaded. From this related question, I changed the commands to:

autocmd VimEnter * GitGutterLineHighlightsEnable

This executes the command after vim has started up.

Pansir answered 24/1, 2014 at 1:14 Comment(0)
S
7

Use

let g:gitgutter_highlight_lines = 1

instead of

GitGutterLineHighlightsEnable

Socman answered 24/1, 2014 at 1:22 Comment(0)
D
6

As you determined yourself, plugins are processed after the .vimrc.

What you can do if you don't like using a VimEnter autocmd, is put a file in your ~/.vim/after/plugin directory for any commands that should run after plugins are loaded.

Durant answered 24/1, 2014 at 5:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.