I'm using Windows 10.
I want to give Vim another shot after having some troubles with it in the past. I'm eager to learn it, but I'm confused. I gave a pretty thorough search to find my answer before I resorted to posting this here, but what is the proper way to install my vim plugins. I see two vimfiles folders in two different directories.
One in the $HOME directory.
C:\User\[USERNAME]\vimfiles
And one in the installation directory.
C:\Program Files (x86)\Vim\vimfiles
Is there a reason for there being two of these ? What's the best directory to install my plugins ?
It is related to 'runtimepath' param. Read :help 'runtimepath' for more info . C:\Program Files (x86)\Vim\vimfiles is system folder with default plugins which are shipped with vim itself. C:\User\[USERNAME]\vimfiles is your local runtimepath. And there you should put your plugins. This way if you have multiple users they all will have own vim environment to work in. If you want you can even set different runtimepath but this is whole another question))
C:\User\[USERNAME]\vimfiles is your vim runtime files and C:\Program Files (x86)\Vim\vimfiles is Vim's runtime files. As long as a feature is present in your vim runtime files and vim request it, it will load them and if its not present there, then it will fallback to his runtime path to find it (i.e. C:\Program Files (x86)\Vim\vimfiles ). So you should always install your plugins, colorschemes, syntaxes, ... in your vim runtime files and also back it up in a safe place and never touch vim's runtime files.
Related
How do I configure Vim running under Windows to be able to edit Golang code? I have spent 3 hours trawling through incomplete, self referential guides on this subject and I grow weary with the resultant frustration.
Ok more details. I have Vim installed. The folder structure is:
Program Files (x86) -> Vim
vim80
autoload
colors
...
vimfiles
An example of my confusion is the fact that the installation guide to vim-plug, in the sections about Powershell, simply says to issue the line:
md ~\vimfiles\autoload
What are these folders relative to?
I have an existing autoload folder but it is under the vim80 folder, hence my confusion. The aforementioned folder structure is the default one created by the Vim installer.
The ~ in powershell refers to $HOME wnich by default means %USERPROFILE%
So ~\vimfiles\autoload are user settings used by vim80/autoload.
The ~ characters is your Userprofile as said by VonC.
You can therefore create the vimfiles folder under your user directories:
C:\Users\username\vimfiles
These will be loaded after the core files under the vim installation location Program files(x86)\Vim\vim80 but both folders same a similar purpose.
Using the user directory is recommended if multiple users are using the same vim installation while having different plugins and a different vimrc.
Note that this also works with the vimrc file:
You can place your _vimrc or .vimrcin C:\Users\username\ and it will be loaded by vim.
For gVim 7.3.46 on Windows 7 64-bit fully updated (I run gVim 7.3.46 because it adds a reliable instance of "Edit with Vim" to the Windows context menu.)
Despite having read an abundance of articles (many of them which repeat the others) I can't get Pathogen to load a vim plugin that already works fine if I don't use Pathogen.
The problem seems to be the location of Pathogen's "bundle" folder as follows:
· IF I place the mru.vim (Most Recently Used Files) plugin in "D:\Program Files (x86)\Vim\vim73\plugin", THEN MRU works just fine — typing :MRU returns a list of recently used files
. IF I place mru.vim in a folder named "bundle", then place the bundle folder in "D:\Program Files (x86)\Vim\vimfiles", or other locations listed below, typing MRU returns "E492 : Not an editor command : MRU"
MY ENVIRONMENT:
· In Windows 7 64-bit, Vim / gVim 7.3.46 is installed in "D:\Program Files (x86)\Vim\vim73\gvim.exe" (Yes, "D", not "C").
· In gVIM, typing :e $VIM returns the following four-lines:
../
vim73/
vimfiles/
_vimrc
· In "D:\Program Files (x86)\Vim\vimfiles\autoload\", I have pathogen.vim. In this location gVim starts without error, and typing :pathogen#helptags() returns no error (one article I read indicated that command was one way to tell if Pathogen was installed correctly).
· My _vimrc file includes the lines:
syntax on
execute pathogen#infect()
filetype plugin indent on
MY PROBLEM:
I've tried copying the bundle folder containing mru.vim to:
· D:\Program Files (x86)\Vim\vimfiles (reputedly the "correct" location for Windows)
· D:\Program Files (x86)\Vim
· D:\Program Files (x86)\Vim\vim73
Multiple articles identify the first entry in that list as the correct location for the bundle folder in a Windows system. That is to say, that in Windows unlike *ix, one evidently does NOT "bury" the bundle folder somewhere down in the *ix .vim folder, or Windows ..\users[userName] folder, or the like(?)
All of those locations for "bundle" produce the same response to typing :MRU — "E492 : Not an editor command : MRU".
I'm at wits end. Any ideas anyone?
(By the by, thanks but I do NOT want to use Vundle / Github / Curl or any other network related solution. I don't use all that many gVim plugins, and the ones I do use I want to download and copy into the bundle folder myself rather than have an unwanted network process involved in that.)
Cheers & thanks for your help,
Riley
SFO
mru.vim should be placed in the bundle folder such that the path is
D:\Program Files (x86)\Vim\vimfiles\bundle\mru\plugin\mru.vim
Although it should really be placed inside vimfiles in your home directory not Program Files
$HOME\vimfiles\bundle\mru\plugin\mru.vim
Pathogen makes it so that every folder in bundle is part of the vim runtime path. This allows every plugin in the bundle folder to have a clean environment for it to store all related files.
For example if you had two plugins that had more than one file (for example they both came with documentation).
Then the file structure of the vimfiles folder would look something like this.
vimfiles/
plugin/
plugin1.vim
plugin2.vim
doc/
plugin1.txt
plugin2.txt
But what happens when you want to remove one of the plugins you need to go find each and everyone of the files (and you might miss some).
With Pathogen installed your directory structure would probably look something like this.
vimfiles/
bundle/
plugin1/
plugin/
plugin1.vim
doc/
plugin1.txt
plugin2/
plugin/
plugin2.vim
doc/
plugin2.txt
Pathogen appends all of the folders under the bundle folder to the vim runtime path. This allows vim to find the files and vim is none the wiser that its not in the usual place.
This also allows for easier removal of plugins. You don't have to go searching for all the files that came with the plugin you just need to remove the relevant folder from the bundle folder.
Just for completion sake. (You don't need to do this if you don't want to)
Installation.
If you used git you can now go to the github page for vim-scripts and find the plugin you want. Since you were interested in using mru the link to the mru plugin is https://github.com/vim-scripts/mru.vim
Now to install the plugin you just need to go into the bundle folder and run
git clone https://github.com/vim-scripts/mru.vim
All the scripts in the vim scripts repository have the proper structure that pathogen is expecting so after running that one command you are done installing the plugin.
I primarily develop on Linux where there is /usr/bin and /bin directories. I know that Windows does not have any real equivalent of either of these besides C:\Windows and C:\Windows\System32. Many command line programs that I port to windows, I simply will write an installer that will copy them to C:\Windows, because I do not feel like having to set a PATH variable. I know that the proper way is to set a PATH variable, but to me C:\Windows is == to /usr/bin. What do Windows programmers have to think about this? Is this a good habit, is there any real disadvantages, and should I actually install to Programs Files and set a path variable via the registry instead?
Install to Program Files (or even the user's AppData folder for user-specific installs), and provide an option to add the directory to %PATH%.
Installing to Program Files has a number of advantages:
Won't conflict with any other files that happen to be in C:\Windows
Won't override some other tool already on the user's PATH
Makes the components of your program more obvious, instead of a random scattering of files in C:\Windows
Avoids dependency conflicts (DLL hell) if you need to include your own DLLs
Giving users the option to add to %PATH% allows users to skip that step if they run into some other kind of conflict with your app (which is less likely with Program Files, but still possible). If you installed into C:\Windows, you'd have no way to avoid such conflicts.
You should install applications to the proper Program Files directory, generally; there are exceptions though. And there are numerous Environment Variables already set for numerous paths on Windows, %PROGRAMFILES% being one of them (and %PROGRAMFILES(X86)% being another, hence 'appropriate' path).
I wish to store my Mac, Windows and Linux vim configuration files in git. On *nix systems, your vim configuration files go in ${HOME}/.vim but for the Windows binary, the same directory is named "vimfiles" Can I configure git to accommodate the different directory name?
You don't need to configure Git, just tell Vim to use ~/.vim for Windows, too, by putting the following fragment into your ~/.vimrc:
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
if has('win32') || has('win64')
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif
My setup is very simple.
On Mac, the versioned directory is:
/Users/username/.vim
On Linux, it is:
/home/username/.vim
On Windows XP (yes), it is:
C:\Documents and Settings\username\vimfiles
They all point to the same GitHub repository.
My settings are stored in a vimrc (no . or _) file located at the root of the repository. Therefore its versioned and commited/pushed/pulled like all the rest.
The actual default user-specific vimrc,
/Users/username/.vimrc
/home/username/.vimrc
C:\Documents and Settings\username\_vimrc
is a real file, no need for a symlink. It contains only one line:
runtime vimrc
that tells vim to read, and execute, my vimrc.
Because of how :runtime works, I don't need to use a real absolute path which would be different on Unix-like platforms and on Windows.
Setting up a new machine or user is as simple as cloning my repo and typing two easy to remember words.
I also need to share config files for vim and other applications between multiple systems, and I found that git was not only overkill but also required manual syncing on each system to get the latest updates and to publish changes. A better solution for me is to put these config files into Dropbox, make all of my systems connect to my Dropbox account, and create symbolic links to these shared files.
For example, I put my vimrc file under Dropbox/conf/vimrc, and then did
ln -s ~/Dropbox/conf/vimrc ~/.vimrc
You should be able to use Windows' mklink to similar effect to create a _vimrc symlink to that same file. In the same way, a common Dropbox/conf/vim directory could be linked to locally as .vim or .vimfiles or whatever your OS' vim executable prefers.
Dropbox keeps a history of changes over the last 30 days, which is enough to handle recovering from most problems for which I needed git. The cool thing is that you can add that new macro or setting to your .vimrc and it is automatically available on all your systems.
Of course this approach is also handy for your other config files, too (.gitconfig, .gitignore, .bashrc, etc.).
Hi guys : I recently (accidentally) removed all folders/files from my .vim folder in mac os x (home directory).
I am trying to add in the Clojure Vim plugin (VimClojure) - its simply a folder which you are supposed to "drop into .vim/plugins".
I have added it, but I don't see any changes to the syntax highlighting when I launch vim. I'm not sure wether vim "sees" the plugin or not.
I'm on OS X .
Any ideas on how to debug the plugin ? In particular
1) How does VIM look for plugins ?
2) Are there files which need to be in $HOME/.vim/ ?
3) Is it sufficient to simply dump the unzip a new plugin file into $HOME/.vim/plugins when installing a standard vim plugin ?
Thanks
About debugging: in order to see whether vim has loaded your plugin you can use :scriptnames and also breakadd file /path/to/your/plugin (or breakadd file *your_plugin_name.vim: I never used absolute paths so I do not know what breakadd will do in this case). Other questions:
Described in :h initialization, precisely :h load-plugins.
Vim does not need any files at all (except vim executable, used shared libraries, dynamic linker and the kernel of course).
Follow installation instructions. Normally plugins are either extracted to ~/.vim or distributed as a singe file that should go to either ~/.vim/plugin (no s!), ~/.vim/colors, ~/.vim/ftplugin or such. I guess you should try to extract it to ~/.vim/plugin, but if archive contains some special directories like plugin/, ftplugin/, colors/, after/ (see /usr/share/vim/vim73 for a list) it is likely that it should go to ~/.vim. Also consider using vim-addon-manager, if plugin was posted on vim.org VAM is likely to be able to install it.
A few points.
How does vim look for plugins? See :help startup so see where and when vim looks for files to load.
Not really. Anything there is just personal customization. Vim will run fine without a .vim folder.
That all depends on the plugin. It sounds to me like the VimClojure plugin may be a little misleading. Do you have a link to the source you are using?
In any case, the first step I always take when attempting to debug a script is check the output of :scriptnames. This command will show you what scripts vim has loaded for the current session. If you see none of the files shipped with VimClojure, you probably made a mistake during the installation.
Another tip is that you really should look in to using a plugin manager such as vundle or vim-addon-manager, or at least the runtimepath manager pathogen. This seems to be the way of the future for vim configuration these days and it makes installing and managing plugins much easier. They also help to keep your .vim folder clean and organized.
The VimClojure directory should either be extraction on top of your .vim folder, or in a bundle folder if your using something like pathogen (which you should!). If you're starting from scratch, consider starting with vimclojure-easy (not to toot my own horn) which is a basic, full install of VimClojure with instructions.