installing plugins in vim

50

22

I had a real difficulty installing vim plugins on mac. I know for a plugin to be installed it has to be seen by runtimepath. According to vim docs, this is

 Macintosh: "$VIM:vimfiles,
 $VIMRUNTIME,
 $VIM:vimfiles:after"

First off, what does $VIM:vimfiles mean?? It is certainly not $VIM/vimfiles, as (~/.vim/vimfiles) does not work. So my options are

1) put my plugin in /usr/share/vim/vim73 (my $VIMRUNTIME, which i know to be BAD)

2) find a way to make vim look at my home directory when including plugins. I have putting my plugin in:

~/.vim/plugin.vim
~/.vim/vimfiles/plugin.vim
~/.vim/plugin/plugin.vim

All to no avail. Can somebody help me out here? Thanks!

Ying

Posted 2012-03-25T21:57:03.040

Reputation: 715

I recommend vim-plug. And for the record, in case you want to install a plugin globally for all users, see my answer here stackoverflow plugins globally

– Dr Beco – 2017-07-10T19:31:46.493

1That runtimepath, as described in the docs, doesn't seem right for a Mac running OS X. I wonder if it refers only to the Mac OS that preceded OS X. Use this command to see what it really is on your machine: :set rtp?. My guess is that the runtimepath on your Mac is set as it would be for a Unix system, and that you should put your plugins in ~/.vim/plugin, not ~/.vim/vimfiles. – garyjohn – 2012-03-25T22:33:15.820

Answers

61

You don't need to do anything for Vim to find your plugins and settings. Except actually putting them in the right place.

  1. On UNIX derivatives, $VIM refers to the directory where Vim's support files were installed. On Mac OS X, a UNIX derivative, Vim's default location is /usr/bin and its support files are installed in /usr/share.

  2. Don't put your plugins/colorschemes/scripts in /usr/share/vim/vim73. Only default files should be there as they will likely be changed the next time you or Apple updates your install.

  3. On Mac OS X (or any UNIX derivative) you must put your plugins/colorschemes/scripts in a ~/.vim directory and your custom settings in a ~/.vimrc file. None of these are there by default: you'll have to create them yourself as well as any needed sub-directories.

  4. Some plugins consist of only one file, pluginname.vim that you should put in ~/.vim/plugin as in:

    ~/.vim/plugin/pluginname.vim
    

    If the plugin and your version of Vim are compatible it should work. Check the plugin's page if it needs some activation command or setting. You'll need to relaunch Vim anyway.

    Many plugins, though, are composed of many files in many directories like autoload, after, doc… You'll have to put the files in their corresponding directories under your ~/.vim, creating them as needed. Taking CtrlP as an example:

    ~/.vim/autoload/ctrlp/<many files>
    ~/.vim/autoload/ctrlp/ctrlp.vim
    ~/.vim/doc/ctrlp.txt
    ~/.vim/plugin/ctrlp.vim
    
  5. Once you are OK with the basics of plugin management in Vim you should try Pathogen or Vundle or some other solution.

romainl

Posted 2012-03-25T21:57:03.040

Reputation: 19 227

1I actually have my plugin in my ~/.vim folder and ~/.vim/plugin folder. when i run :scriptnames in vim, they never show up. What could be the issue? my vim installation must not be 'looking' in this directory... – Ying – 2012-03-28T11:10:34.860

The very first item in :set runtimepath? should be ~/.vim what is it? What plugin(s) are you trying to install? – romainl – 2012-03-28T11:54:01.737

Hmmm, this is the output. runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,~/.vim/after

so it certainly seems right. im trying to install minibufexplorer – Ying – 2012-03-28T13:59:07.210

shoot...i know why. permissions were not right on the folder. The script is getting seen now! – Ying – 2012-03-28T14:05:08.137

You should investigate the issue: it's not normal that $ mkdir .vim creates a directory with wrong permissions. – romainl – 2012-03-28T14:33:29.223

4

Better use ~/.vim/plugin/ directory to put vim plugins files (as mentioned by Vim help command).

See http://www.youtube.com/watch?v=Dmv6-dguS3g&feature=player_embedded#!

In vim, see the help: :h plugin

Gilles Quenot

Posted 2012-03-25T21:57:03.040

Reputation: 3 111

1

Since this question not specifically about configuring paths in order to have plugins work, an alternative to mucking around with all the path stuff is to just source the specific plugins you want in vim from your .vimrc (assuming it's working) by adding the line :source PATH/TO/FILE.vim. Vim generally checks for .vimrc right in the home directory ~/. If it does not exist, try creating it there, and from within it either sourcing the plugin(s) you want as described, or first doing something else you'll notice when starting vim such as :echo your vimrc says hello.

SeldomNeedy

Posted 2012-03-25T21:57:03.040

Reputation: 208

I added "source: PATH_TO_FILE/plugin.vim". Now when I load any file in vim. I get this following error: "E172: Only one file name allowed: source: PATH_TO_FILE/plugin.vim" – yogeesh – 2016-04-29T04:57:00.347

@yogeesh You probably have spaces in the filename. In vim, you must delimit these using a backslash ''. So, if your filename or path have spaces in them the line in your file will look more like :source /THE\ PATH/TO/MY\ FILE – SeldomNeedy – 2016-04-29T20:15:20.320

I figured out the problem. I was not aware of rtp! – yogeesh – 2016-04-30T15:46:28.527