Question

I know there are multiple posts on this question but I have tried with no avail to get this simple part of Vim to work. I would like to get the pathogen plugin to work with Vim. As a few points, I am working on a Windows system. I have downloaded pathogen via github and have created the directories .vim and subdirectories autoload and bundle. My .vimrc is the default created with mkvimrc with:

call pathogen#infect()
syntax on
filetype plugin indent on

added to the bottom. Addressing other postings I have seen:

:set cp? = nocompatible

One area I am guessing is part of the issue is after I run :scriptnames I don't get the .vim directory. I only get the Vim\.vimrc and vim73 directories. How do I address this? I have been at this a long time and apologize if this is obvious to others here.

Was it helpful?

Solution

On Windows the default location of the local user configuration is $HOME/vimfiles. If your files are in $HOME/.vim then you either need to move them to vimfiles or add .vim to your runtimepath in your .vimrc:

set runtimepath+=~/.vim

Also, if Pathogen is in a subdirectory of bundle you will need to run it explicitly from there, since by default Vim will only look in ~/.vim/. Put this in your .vimrc before the pathogen#infect call:

runtime bundle/pathogen/autoload/pathogen.vim

OTHER TIPS

The solution for me was re-downloading the pathogen.vim as it had somehow failed to download by failing to follow a redirect. The URL specified on tpope's github has the following step:

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

You will know the redirect failed to download as the contents of pathogen.vim will be a 302 redirect page. Just download from the URL contained in the redirect e.g:

wget -N -O ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim

Open Vim with disabled plugins and type :set rtp - notice that:

  • if you are on Unix, then by default: the first goes ~/.vim and the last goes ~/.vim/after;
  • if you are on Windows, then by default: the first goes ~/vimfiles and the last goes ~/vimfiles/after.

This is sort of Vim convention. after directories are used to forcefully override Vim's defaults or plugins' settings, which is important sometimes. That's why they are the last in the rtp.

Pathogen actually parses the structure of your current rtp variable and uses it to inject paths of plugins into the rtp properly. For example, look at my rtp:

runtimepath=
~/.vim,
~\.vim\plugins\NERDCommenter,
~\.vim\plugins\NERDTree,
~\.vim\plugins\SameSyntaxMotion,
~\.vim\plugins\Tabular,
~\.vim\plugins\UltiSnips,
~\.vim\plugins\c.vim,
~\.vim\plugins\clang_complete,
~\.vim\plugins\CountJump,
~\.vim\plugins\delimitMate,
~\.vim\plugins\fswitch,
~\.vim\plugins\matchit,
~\.vim\plugins\matlab,
~\.vim\plugins\neocomplcache,
~\.vim\plugins\protodef,
~\.vim\plugins\python-syntax,
~\.vim\plugins\solarized,
~\.vim\plugins\syntastic,
~\.vim\plugins\vim-creole,
~\.vim\plugins\vim-latex,
~\.vim\plugins\vim-markdown,
~\.vim\plugins\vim-python-pep8-indent,
~/vimfiles,
D:\Applications\Vim/vimfiles,
D:\Applications\Vim,
D:\Applications\Vim/vimfiles/after,
~/vimfiles/after,
~\.vim\plugins\Tabular\after,
~\.vim\plugins\UltiSnips\after,
~\.vim\plugins\vim-markdown\after,
~/.vim/after

Notice how pathogen injected paths. It has detected that several plugins have after directory and put them right before ~/.vim/after - so that the last word is always mine.

To achieve this pathogen needs a pair of either ~/.vim and ~/.vim/after or ~/vimfiles and ~/vimfiles/after or even ~/stuff and ~/stuff/after (not sure about the last case though) as anchors to inject plugins' paths in the right order.

If any directory from this pair is missing, then you will have some nasty experience with pathogen (as I did sometime ago, until I found out all the aforementioned stuff and skimmed through pathogen source code) - because paths will not be able to be injected correctly.

Now you can see that the answer provided by Prince Goulash is completely wrong:

  1. the first mistake is that he has appended ~/.vim to rtp whereas he should have prepended it;
  2. the second mistake is that he didn't append ~/.vim/after.

The correct solution looks as follows. If you have to work on different platforms including Windows you should rather add this into your .vimrc (I keep this in mine as well - you can infer it from my rtp example):

if has('win32') || has('win64')
  set runtimepath^=~/.vim
  set runtimepath+=~/.vim/after
endif

This snippet will ensure consistency across platforms. You can now use Unix-like directory .vim even in Windows and forget about the vimfiles crap - which is IMO ugly and awful.

After that you call:

call pathogen#infect('plugins') " or wherever your plugins reside
call pathogen#helptags()        " optional, but really cool

NOTE: 'plugins' denotes the ~/.vim/plugins directory, so it is relative of ~/.vim.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top