Vim : Here, There, Everywhere

This is my first meta-post. A meta-post is post that will be referenced by other posts, it will be filled over the time with the information needed by normal posts.
This one represents you the directory/file structure of the vim configuration.

Let’s talk about the ‘rtp’ or the runtime path. The runtime path contains paths separated by comma. Every such path points to directory that can be structured as your $HOME/.vim. I’m going to explain this structure later in this post. For now it is important for you to understand that when vim starts it loads data and configurations from the directories in the runtime path.
By default this path contains:
– Your $HOME/.vim directory.
– System-wide configuration located in place such as ‘/usr/share/vim/vimfiles’.
Configuration located where vim is installed, for example ‘/usr/share/vim/vim73’.
– System-wide after configuration for example ‘/usr/share/vim/vimfiles/after’.
– Your own $HOME/.vim/after directory.
You can modify this path.

Again – the structure of your $HOME/.vim directory is the same for the system-wide vim directories and the ‘after’ directories.

  1. $HOME/.vimrc(_vimrc) – This file contains an Ex script that will be executed every time you start vim. So your personal configurations are likely to be here. Run :help startup for detailed information.
  2. $HOME/.vim/after – From the Vim help : ‘This is for personal preferences to overrule or add to the distributed defaults or system-wide settings (rarely needed).‘ It has the same structure as the $HOME/.vim directory.
  3. $HOME/.vim/autoload – This directory contains vim scripts. These scripts are not loaded before special functions defined in them aren’t called. This means – lazy scripts. Imagine that a file, named ‘meddle.vim’ is located in the autoload directory. Now if in the file we have a function definition like this:
    function meddle#boo()
        echo "Booooo!"

    We are able to call it from anywhere executing ‘:call meddle#boo’. Only if we call it the script will be loaded and the function executed. Run :help autoload for detailed information. Maybe you’ve heard of the ‘pathogen’ plugin? This plugin uses the auto-load functionality.

  4. $HOME/.vim/bundle – This is not a directory used by Vim by default. It is used by plugin managers, such as Vundle and Pathogen to store and load the plugin bundles. The directory is first introduced by Pathogen.
  5. $HOME/.vim/indent – This folder contains files containing indentation rules. For example if you place a ruby.vim file here with rules for ruby indentations, these rules will be applied to all the filetype ruby files.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s