Monday, April 15, 2013

VIm and plugins

KNOW - basic VIM
basic command line unederstanding.

VIM is probably one of the most misunderstood and under appreciated text editors available.  Known as the learning curve from hell, vim though is incredibly popular because it's so powerful and so customizable -- and yes HARD TO LEARN.

Today, I want to talk about plugins.  For the uninitiated, plugins for Vim are scripts that customize vim and do some pretty amazing things.  If there is something you want for Vim chances are there is a plugin for it. 

Of course, getting plugins is easy -- once you install Pathogen. Pathogen IS the plugin manager for the modern era.  SO let's start installing it.

NOTE:
~/ is a shortcut to the home directory.  If your name is Fred.

/home/fred
$HOME 
~/ 
 
all mean the same thing.
 
mkdir -p ~/.vim/autoload 
 
mkdir -p  ~/.vim/bundle 
 
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
 
Easy.

First, we make a new directory.

Vim uses .vim, a hidden directory (ls -al in case you don't know how to list directories that are hidden) and store them all in autoload.  That's where pathogen is going to store pathogen.
bundle is where ALL plugins are going to go from now on.

NOW...that we have pathogen installed, add pathogen to the .vimrc file.

(in case you don't know it, .vimrc is the hidden file that you can use to customize the look and feel of vim.

 "---------------------------- Load pathogen ----------------------------"
execute pathogen#infect()
syntax on
filetype plugin indent on
 
DONE!!!!!!!!!!!!!
Now let's grab some plugins.  Now I might add that the documentation I've personally found tends to say -- just use it.  Let's be nicer.
 
the git website is where all vim plugins are stored. 
 
https://github.com/vim-scripts
 
Now let's install the tagin plugin.  

https://github.com/vim-scripts/taglist.vim

(Any website that lists popular plugins will always include a link like this so don't worry.

ONCE you get to that page, feel free to be lost.  I was :)

Now look for a link that says:

git: read only
To the right of it is an address you want to grab as you'll need it.
In this example, I'm using the taglist one.
IF it's on http (e.g. 

http://github.com/vim-scripts/taglist.vim.git

this is simply a matter of changing the http to git as in:

git://github.com/vim-scripts/taglist.vim.git <- this is what you want!!!

git clone git://github.com/vim-scripts/taglist.vim.git 
 
 
Now since this is a clone you HAVE to make sure you are in a particular directory.  Specifically the bundle directory

cd ~/.vim/bundle

 

you can add a directory path if you want but keep it consistent.  I like everything under bundle myself so...
git clone git://github.com/vim-scripts/taglist.vim.git  /fred/bob

will put it there.  WHY you would WANT to is beyond me but you can.


Incidentally, if you don't have git, grab it. 
 
apt-get install git
yum install git (etc.)

Essentially what you are doing is syncing the files on the server with your local directory.  Granted you could...copy them down, make the directories, etc. but this is far easier.

DONE!
 
Have fun!
 
 

No comments:

Post a Comment