Search code examples
windowsvimnerdtree

Vim does not execute plugins in editor, only in application


I am on windows 10. I set up my files like this.

~/.vimrc

set nocp
source ~/vimfiles/autoload/pathogen.vim "location of my pathogen.vim
call pathogen#infect()
call pathogen#helptags()

autocmd vimenter * NERDTree

syntax on

filetype plugin indent on

~/vimfiles/autoload/pathogen.vim

~/vimfiles/bundle/nerdtree

When I open via the desktop application Vim I can use the :NerdTree command okay, I can also use other pluings, but when I open the vim editor from git bash or cmd.

One thing to note is that I do not need the autocmd vimenter command to run :NERDTree in Vim application, but it errors when I try to open :NerdTree from the vim editor.

Any ideas for what I can check?


Solution

  • On Windows, Vim expects your vimrc to be in either of these two locations:

    • %UserProfile%\_vimrc (note that it's a _, not a .),
    • %UserProfile%\vimfiles\vimrc (note that there's no _ or . anymore).

    The latter is generally recommended because it allows you to keep all your Vim stuff under a single, easy to move around, directory.


    Once you have moved your vimrc to a correct location you can remove the first line which is completely useless as Vim sets the nocompatible option itself when it finds a vimrc at an expected location.

    See :help vimrc and :help 'nocompatible'.


    The second line is also useless because lines 3 and 4 use a feature called "autoloading" through which Vim already knows where to find those functions.

    See :help autoload.