What is the difference between vim72 and vimfiles folder? - text-editor

I am learning VIM. The VIM folder in the windows has two subdirectories VIM72 and VIMFILE. What is the difference between them? Where should I install my plugins?

Usually VIM72 (depends on the vim version) is the 'runtime' directory, I believe this is where vim is searching for all the stuff that it needs during 'runtime'. You would install your custom stuff, e.g. plugins, in your '$HOME/.vim' directory on linux (plugins in $HOME/.vim/plugin).
On windows it seems to be the vimfiles directory (you asked about VIMFILE on my windows system and vim71 it is vimfiles).
So I would try to store plugin in vimfiles\plugin directory on your system.
The difference would be that in VIM72 you would have all the runtime stuff that comes prepackaged with vim including binaries. You can install your own stuff in your vimfiles directory which will be usually searched first for stuff like syntax highlight, color schemes, plugins, documentation and so on.
You can find out the location of your vim72 directory, the location for your custom stuff like vim72/plugins, vim72/colors for colorshemes and so on, from vim do:
:echo $VIMRUNTIME
And finally, vim72 is used by vim 7.2 so when the version changes it will use different directory like vim73 and so on.

Expanding very slightly on stefan's answer:
Like he says, ~/.vim for linux-related systems, and usually vimfiles for gvim on Windows - this is your home vim directory.
You should put all of your own plugins into vimfiles to make sure that when you upgrade your vim installation you don't lose any of the custom plugins or modifications.
For example
There is a syntax file called cpp.vim in vim72/syntax.
If you now want to change a few things in this syntax file (say to add an extra keyword) you could have a copy of this syntax file in vimfiles/syntax with the additional keyword syntax rules.
Now when you upgrade vim to 7.3, you still have all of your custom plugins and settings.
If you were to instead change vim72/syntax/cpp.vim, when you next upgraded vim these files would be overwritten by the new versions and any changes that you made would be lost.
Plus, since vim72/syntax/ contains all of the original syntax files, it would be more difficult to tell which of these you had customised.

That 'vimfiles' directory is where you can install things system-wide without touching Vim's installation directory ('vim72'). The directory 'vim72' is subject to change when upgrading and a new major or minor version will use a different directory (e.g. Vim 7.1 used 'vim71' and Vim 8.0 will use 'vim80').

Related

problems installing vim-misc and vim-session plugins on mac / macvim

When I follow github instructions for vim-misc and vim-sessions, after unzipping to /Users/<me>/.vim/misc and /Users/<me>/.vim/vim-session-master, and then restarting macvim, I get
:helptags ~/.vim/doc
E150: Not a directory: ~/.vim/doc
Also tried putting the two folders in /Users/<me>/ (where my .vimrc is) and in the two locations pointer by $VIM and $VIMRUNTIME from within macvim (/Applications/MacVim.app/Contents/Resources/vim) all to no avail.
I guess I really don't understand how running the :helptags <whatever> starts up/completes installation of these plug-ins anyway?
Before using using a plugin managers, plugins used to go directly into ~/.vim, not into ~/.vim/pluginname. That's when we ran :helptags ~/.vim/doc.
Then we had plugin manager, each with different specific way of doing things. Some even take care of registering the documentation of the plugins installed.
IMO, you'd better find a plugin manager suited to your need and use it. I remember a Q/A on vi.SE, you could start by reading it.
If you prefer to install plugins manually instead of using one of plugin managers like vim-plug or others then you should add plugin directory to your runtimepath. Place this line to your .vimrc set runtimepath+=/path/to/plugin. I would not recommend to place plugins directly to ~/.vim directory, use sub-folder instead (e.g. /Users/<you>/.vim/plugins).

Vim 7.3 on Ubuntu 12.10 doesn't have 'ftplugin' directory anywhere

Vim 7.3 on Ubuntu 12.10
I recently installed vim from the Ubuntu software center. So far, I've installed the following vim plugins: NERDTree, rails and ack.
I'm taking a course on python and another one on Ruby on Rails. I was surprised that vim didn't recognize the languages as far as indenting goes. Checking various questions and answers on this forum, as well as checking vim help, I see that there should be a directory named 'ftplugin' in the $VIMRUNTIME directory. My $VIMRUNTIME is just the same as $HOME which is ~/, but there is no 'ftplugin' in my home directory. There's also nothing like that in ~/.vim. Does that mean I don't have any filetype plugins?
If I don't, where can I get the usual set?
edit
Just to be clear: upon install, Vim doesn't do anything to your home directory. The ~/.vim directory and any subdirectory are to be created by the user: it is where you put your config so you are in charge.
endedit
You must create those directories yourself, no matter what OS you are using. On UNIX-like systems (Linux, Mac OS X…) all your stuff is supposed to go into ~/.vim:
$ cd
$ mkdir .vim
$ cd .vim
Some plugins may need to be placed into specific subdirectories:
~/.vim/autoload
~/.vim/plugin
etc.
You can:
create those directories just like you created ~/.vim and place all the files manually
$ unzip the plugins right there in ~/.vim, the necessary directories are created for you
use some plugin manager like Pathogen or VAM or Vundle and/or a VCS…
I'd advise you to start slow. Just install everything manually: it will help you getting more comfortable with the whole thing.
Anyway, since you have already installed a bunch of (useless IMO, except rails) plugins you probably already know all that.
Vim already has the necessary ftplugins, you only need to tell Vim to "activate" them by default. Add these two lines to your ~/.vimrc (create that file if you didn't already):
filetype plugin indent on
syntax on

How to backup vim configuration with plugins?

I understand to backup my vimrc file but what about my plugins? Will I have to reinstall them if I move to another machine? Or can I just copy paste the directories in my vim folder ( but what if i go from windows to linux) ?
Generally, it is sufficient to take the vimfiles/.vim directory with you. However, in my experience the Linux builds of Vim are much more fussy about plugin line-endings than the Windows ones. Therefore, it is worth checking that all of your plugins and other vim configuration files have Unix line endings so that they work on Windows and Linux without issues.
In my set-up, I have the whole of .vim under version control: this makes synchronising multiple computers very straightforward. To make this work well, put your _vimrc into your vimfiles directory and name it (e.g.) vimrc. Then in the place where you normally have _vimrc add a file with this content:
runtime vimrc
Do the same for _gvimrc if you have one. This means you can keep everything in one folder (plugins and vimrc) and keep that folder under version control or just synchronise it by some other means if you prefer.
This might help: http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/
In most cases taking the directories with you should do the trick.

gVim Portable plugins

Can someone give me a detailed instalation procedure for gVim Portable and important C++ and python development plugins ... like OmniCppComplete, NERDTree, supertab etc ...
or better yet, a prebuilt version
thx
Using plugins on portable vim will require slightly different steps than the regular install. From the configuration page, your .vim file should probably be in Data/settings/.vim instead of ~/.vim
Follow the plugin install instructions and substitute ~/.vim with ((where you put PortableGvim))/Data/settings/.vim
If a plugin does an automatic install, then you may need to move files from ~/.vim
You may find it easier to grab someone else's vimfiles. Mine are on github.
As for the plugins themselves, I got started with this post. See also this SO question.
For what it's worth, if you can live with there being possible issues if you use a computer with vim installed and vimfiles present in the $HOME directory, you can simply take your vim72 directory, your vimfiles directory and your _vimrc (and _gvimrc if you have one) and put them in e:\vim (assuming E: is where the USB stick is mounted). You can then just run e:\vim\vim72\gvim.exe and it will load the configuration from e:\vim\_vimrc and e:\vim\vimfiles. If you plug it into a computer that mounts it as F:, then just run f:\vim\vim72\gvim.exe obviously.
Importantly, this does not require messing about with PortableGvim (which I've never really seen the point of since gvim is essentially portable anyway if you ignore the possible $HOME issues) and allows you to easily synchronise all of your settings between your desktop vim installation and your portable one.
On top of this, I also put vimrc in c:\vim\vimfiles and have _vimrc in c:\vim with the following contents:
runtime vimrc
and then put the whole of c:\vim\vimfiles under version control. This makes it very easy to keep the copy on the USB stick and the copy on the Windows PC (and the copy on my home Linux PC and... and...) synchronised.

Linux/Ubuntu directory location ~/.vim/syntax/

Where is the default location for the folder ~/.vim/syntax/ on a Linux system? I am trying to add a Python addon.
You are looking for the 'runtimepath' option. The documentation is pretty detailed (use :help runtimepath) but I'll try and summarize it here:
The runtimepath option contains a list of paths, separated by commas, where vim looks for plugins, syntax files, etc. On unix, the first path is $HOME/.vim/ (aka ~/.vim/), which means that Vim looks for syntax files in your home folder first before it looks anywhere else. Vim looks for your extra files by searching ~/.vim/plugin/*.vim or ~/.vim/syntax/*.vim, depending on what type of add-ons it is loading.
The next path in runtimepath is usually /usr/share/vim/. Vim will also search this folder for plugins etc (vim looks for /usr/share/vim/plugin/*.vim, etc). This folder is where you should put add-ons when you want them available to every user.
The last path in runtimepath is usually /usr/share/vim/vim72/, or whever Vim was installed to. This tells vim where to find and load add-ons which came bundled with that particular version of Vim.
Now, Most add-ons have a mechanism so that once they have been loaded from, say, your ~/.vim/syntax/ folder, they cannot be loaded from anywhere else. So even though syntax/python.vim comes bundled with Vim and is available in /usr/share/vim/vim72/syntax/python.vim, if an alternative version is instead loaded from ~/.vim/syntax/python.vim, then the bundled syntax is ignored. This is how you can override bundled add-ons using your ~/.vim/ folder, and you can also override them for everyone by putting addons in /usr/share/vim/. The other advantage of this setup is that you can always download the latest versions of the default bundled plugins without overriding any custom plugins you may have added.
If you were to put all your addons into /usr/share/vim/vim72/, you can no longer update to the latest bundled addons without overriding your custom addons, so you should be putting addons for yourself into ~/.vim/, or addons for all users into /usr/share/vim/, but never into /usr/share/vim/vim72/.
~ is a UNIX shortcut that means "the currently logged-in user's home folder", which is typically something like /users/<username>. You should be able to find that folder by executing
cd ~
mkdir -p .vim/syntax
cd .vim/syntax
The mkdir command creates the directory if it doesn't already exist.
If you want to add the syntax for multiple users, ire and curses is on a better track.
From the docs:
$VIMRUNTIME/syntax
On my (Ubuntu) machine, this is /usr/share/vim/vim72/syntax/.
/usr/share/vim/vim72/syntax/
I added the file in the above location and it is working for puppet scripting

Resources