Vim

Nov 25, 2014

Table of Contents

Introduction

Execute the command vimtutor on Linux for a very good introduction to Vim

Another two good built-in introduction to Vim documents: :help usr_02 and :help intro - run these commands from within Vim. If you never navigated the Vim documentation before, there are some tips that I have here

Learning the vi and Vim Editors - the best book available on the subject

Swaroop CH's Byte of Vim - a very good introduction (plus more) to Vim. He also has a good intro to Python book if you are interested in that.



Vim version: 7.3.154

Terminal: Gnome Terminal 3.0.1

Screen version: 4.00.03jw4 (FAU) 2-May-06

I have been using Vi/Vim for about 13 years now. I thought I knew most of what there was to know about Vim until this year when I decided to see what else I could do with Vim and wow, I didn't realize how little I was utilizing it's capabilities. This was primarily as a result of finding an article about using Vim as a Python IDE. I discuss this more in the plugins section.This is not an intro to Vim document. It is meant more as a reference document after you learn the basics. There are MANY websites and books available where you can learn vi. Here are one's that I recommend:This document does not include every single Vim command especially if they are very basic (ie. what the navigating commands "hjkl" do) nor more advanced Vim topics (ie. nothing on scripting at the moment). You can think of it as a Vim cheat sheet or user manual, but I feel it is much more then that which is why I am referring to it as a reference document. I have included the commands/capabilities that I often forget or that I feel may not be as well known to the casual Vim user. Also something that I have not seen on many other Vim related websites, I include the most common commands to the plugins as well as where to go for additional information on said plugins. I hate having to track down the help for a plugin that I only use occasionally.some of the commands are in ex mode. Make sure you notice if there is a colon (:) or not before a command. This makes a big difference.if a letter below is capitalize, then ensure you capitalized it when using it.below is the environment that I use Vim in. If you use something different, there may be some slight differences in the below commands/plugins:*Most of the time I have to install the full Vim package with the command:because most distros only come with the minimial versions of Vim (vim-common and/or vim-tiny).If you feel any of the content in this document is wrong or there is something that I should add, I would appreciate it if you would contact me and let me know. Thanks!

Navigation

Forward a full screen: Ctrl-F

Backward a full screen: Ctrl-B

Forward a half screen: Ctrl-D

Backward a half screen: Ctrl-U

Help: :help scrolling

To turn recording on: q<name of buffer> - I use "a, b, c, etc." for the name of my buffers

- I use "a, b, c, etc." for the name of my buffers To turn recording off (when you are done entering your commands): q

To retrieve your buffer: @<name of buffer>

See a list of your recorded commands (actually it includes all of your registers): :reg

Help: :help record and :help 10.1

Top line of screen: H

Middle line of screen: M

Last line of screen: L

5th line after the top line of screen: 5H

5th line after the middle line of screen: 5M

5th line before the last line of screen: 5L

First character of the next line: +

First character of the previous line: -

First nonblank character on the current line: ^

Beginning of sentence: (

Beginning of next sentence: )

Beginning of paragraph: {

Beginning of next paragraph: }

5th line of the file: 5G

Last line of the file: G

First line of the file: gg

Return to the previous location you where just at: ``

Help: :help object-motions and :help various-motions

Current line (not necessary to include the period "." It is assumed by default): :.

Last line: $ Every line: % Next 10 things (things can be words, lines, etc and + means one, ++ means two, etc): +10 Previous 10 things: -10 Move lines 25 to the end of the file 5 lines above current line: :25,$m.-5 Display line numbers from the current line to the next 10 lines:. ,+10#



I use the below scroll commands and record commands constantly. The record commands allow you to record a series of steps and then perform them again later on. I just learned about the move commands and I feel I will be using them more. Seefor more info on navigation.Scrolling:Record Commands:Move toIn ex mode (when you type a colon ":" then a command), the following are shortcuts:

Inserting

Append at the end of the word: ea

Append at the beginning of a sentence: Shift-I

Insert the character above: Ctrl-Y

Insert text of file at the current cursor position: :r file

Deletion

Delete from the cursor to the end of the line: D

Delete from the cursor to "pattern" going backwards: d?pattern

Delete from the cursor to "pattern" going forward: d/pattern or :/pattern/d

or Delete the line below the line containing pattern: :/pattern/+1d - you can leave off the 1 because 1 is assumed by default but I find it clearer to keep it

- you can leave off the 1 because 1 is assumed by default but I find it clearer to keep it Delete from line containing pattern1 to line containing pattern2: :/pattern1/,/pattern2/d

Delete from the cursor to top of screen: dH middle of screen: dM and bottom of screen: dL

middle of screen: and bottom of screen: Move the txt from current line to 1st line containing pattern and move to line after line 10: :.,/pattern/m10

Delete the next three lines and place into buffer named "b": "b3dd

Put the contents of buffer named "b" after the cursor: "bp

Delete lines 1-20: :1,20d

Delete from current line to end of file: :.,$d

Delete all lines in file: :%d

Go through your deletion buffer: "1pu.u.u - the "u" undoes the previous deletion and "." puts the next one

Yanking/Putting

Put before cursor: P

Put after cursor: p

Yank lines 1-10: :1,10y

Put the links you just yanked: :pu

Yank from the cursor to pattern going forward: y/pattern

Yank from the cursor to pattern going backwards: y?pattern

Yank current line into buffer "a": "ayy

Put contents of buffer "a" after cursor: "ap

Yank the next 5 lines into buffer "b": "b5yy

Put contents of buffer "b" before cursor: "bp

Yanking and putting text is a very useful feature

Searching

Search for string within a word boundary: /\<string\>/

To find the next occurrence of a word (while you are positioned over it): * and # (backwards)

To search for a word in reverse: N

Turn on search highlighting: :set hlsearch

Turn off search highlighting: :set nohlsearch

Do not ignore case: :set smartcase

Ignore case: :set ic

The characters .*[]^%/\?~$ have special meaning. If you want to use them in a search you must put a backslash (\) in front of them.

have special meaning. If you want to use them in a search you must put a backslash (\) in front of them. Go to first space character: /\s

Do not start search from the top once it hits bottom: :set nowrapscan

Print all lines that contain "pattern": :g/pattern

Print all lines that do NOT contain "pattern": :g!/pattern/ or :v/pattern

or Get a list of your search history: q/ - use Ctrl-c twice to exit this mode

Help:andNote, also look at the substitution section for more string matching options that you can also use when searching

Substitution

Many examples have the percent sign character '%' which means perform the change on the entire file. If this is not included the substitution works only on the current line (or a range of lines if you specify that).

The caret character '^' matches at the beginning of a line and the dollar sign '$' at the end

Substitute y for every occurrence x in lines 1 through last: :1,$ s/x/y/g

Substitute y for every occurrence x in lines 50-75 through last: :50,75 s/x/y/g

To replace all occurrences of "hi" with "bye" in the current line: :% s/hi/bye/g

Replace all occurrences of "ACCEPT" with "DENY -i eth1":

:% s/ACCEPT/DENY -i eth1/g

To replace the text "red" with "blue", but only when red is the first word on the line: :s/^red/blue/

Remove anything that has the word "line" follow by a space, follow by one or more digits: :% s/line \d* //g

Remove a forward slash at the end of a line (notice you must backslash the forward slash): 0,$ s/\/$/

Substitute everything that has ".20" in it with ".200" on just line 16:

:16 s/.20\>/.200/g

Use "c" to be prompted to replace each substitution: :% s/hi/bye/c

Use "i" for for the match to be case insensitive: :% s/hi/bye/i

Use "I" (uppercase "i") for for the match to be case sensitive (which is the default setting but you may want to use this if you set case insenstive searches in your .vimrc file "set ignorecase"): :% s/hi/bye/I

Remove all word (\a) and underscore characters (_). Note to match two different things, you need to use this format \(pattern1\|pattern2\): :% s/\(\a\|_\)//g

Remove all blank lines (regardless if they have any spaces "\s" and/or newlines "

"): :% s/\(^\(

\|\s\)*\)//g

Delete anything that says "port <any amount of numbers>/<tcp or udp>" (example: port 443/tcp or port 161/udp) :% s/port\s\d*\/\(tcp\|udp\)//

You can find more examples here: http://vimregex.com/#substitute

Vim's substitution capabilities are one of it's most powerful features. A few helpful notes before jumping into the examples:Now for some examples:One of the most powerful features of substitution is being able to use regular expressions. Below are some examples I have used:Help:, or Substitution on vimdoc

Changing Case

Use g~ followed by any movement command to change the case to the opposite of what it currently is (aka "toggle"). Here are some examples: To the end of the line: g~$ (ie. "GoodBye" will change to "gOODbYE" The next three lines: g~2j The next three characters: g~3l

followed by any movement command to change the case to the opposite of what it currently is (aka "toggle"). Here are some examples: Use gU followed by any movement command to change any lowercase characters to uppercase. (ie. gUw will change "GoodBye" to "GOODBYE")

followed by any movement command to change any lowercase characters to uppercase. (ie. will change "GoodBye" to "GOODBYE") Use gu followed by any movement command to change any uppercase characters to lowercase. (ie. guw will change "GoodBye" to "goodbye")

followed by any movement command to change any uppercase characters to lowercase. (ie. will change "GoodBye" to "goodbye") Toggle the case of the current line: g~~

Uppercase the current line: gUU

Lowercase the current line: guu

Lowercase an entire file: :%s/.*/\L&/ or from the first line: guG

or from the first line: Uppercase an entire file: :%s/.*/\U&/ or from the first line: gUG

This sections shows the different options to change the case of characters and wordsHelp: Switching the case of characters

Replacement

To the end of the line: c$ or just C

or just To the beginning of the line: c^ or c0

or Just a single word: cw

The next two words: 2cw

The previous word: cb

The previous two words: 2cb

An entire line: cc or S

or From the cursor to the top of the screen: cH middle of screen: cM and bottom of screen: dL

middle of screen: and bottom of screen: From the cursor to "pattern" going forward: c/pattern

From the cursor to "pattern" going backwards: c?pattern

This sections deals with word and line replacementChange:

Marking

Leave a mark named "a" where the cursor is currently: ma

Move to the mark "a": `a

Move to the beginning of the line where the mark "a" is located: 'a

Go to the previous location: Ctrl-o

Go to the next location: Ctrl-i

You can place an invisible marker in your file that you can reference later. Note, these are deleted once you close the file.Help:

Spell Checking

Enable spell checking: :set spell spelllang=en_us

Disable spell checking: :set nospell

For the misspelled word, suggest a replacement: z=

Repeat the replacement for the misspelled word for all matches: :spellr

Move to the next misspelled word: ]s

Move to the next misspelled word, going backwards: [s

Add word to dictionary: zg

Remove a word from the dictionary: zug

Enable spell checking: <F5>

Disable spell checking: <F6>

Yes, that's right, Vim has spell checking and it rocks!Here are the most useful commands:If you are using my advanced .vimrc file, I mapped the following keys:Help:

Visual Mode

Start visual mode: v - this works on a character basis, but when you move down it selects the entire line

- this works on a character basis, but when you move down it selects the entire line Start visual mode: V - this works on a line basis (

- this works on a line basis ( Start block visual mode: Ctrl-v - this is the most useful mode. It allows you to highlight just certain parts of the text using either the arrow keys or navigation keys

- this is the most useful mode. It allows you to highlight just certain parts of the text using either the arrow keys or navigation keys Change while in block visual mode: c - this is used the same way as insert above, but you are changing the text you have highlighted. Just like insert, the changes do not reflect for all lines (just the first line) until you hit ESC key

- this is used the same way as insert above, but you are changing the text you have highlighted. Just like insert, the changes do not reflect for all lines (just the first line) until you hit ESC key These are the options you have with highlighted text: Change the case of characters: ~ (tilde symbol) Indent right: > (greater then symbol) Indent left (un-indent): < (less then symbol) Change text: c - in block mode, the same things applies as the note I include below for insert mode Yank text: y Delete/Cut text: d (To paste text move cursor to desired location and use P to put text above the cursor or p for below

For more examples, see: :help text-objects

For more examples, see:

Another very useful feature is the ability to insert while in block visual mode: I

Note: when inserting, what you are inserting will ONLY appear on the first line, but when you are done and hit the <ESC> key about 3 seconds later it should put what you inserted on every line you had selected

visual mode: Note: when inserting, what you are inserting will ONLY appear on the first line, but when you are done and hit the <ESC> key about 3 seconds later it should put what you inserted on every line you had selected Select the entire file (usefull when copying and pasting): ggvG

Select from where the cursor is currently positioned to the end of file: vG

Exit out of visual mode: <Esc> key

I just started using visual mode, but I really like it for certain things. My favorite use of it so far is to quickly indent or add comments to a block of code.to get out of any visual mode, hit the <ESC> key and wait about 3 seconds.Help:

Miscellaneous

You can create abbrevations. For exampele :ab us United States will allow you to just type "us" and it will be replaced with "United States." To disable the abbrevation type :unab us

will allow you to just type "us" and it will be replaced with "United States." To disable the abbrevation type List all abbrevations :ab

Enable the ability to use your mouse in xterm: :set mouse=a - note, this is enabled by default in my advanced vimrc file and you can toggle it on/off with Ctrl-m. The only reason I ever disable it is when I need to highlight text for copying and pasting. With mouse support enabled Vim goes into visual mode when you highlight text.

- note, this is enabled by default in my advanced vimrc file and you can toggle it on/off with Ctrl-m. The only reason I ever disable it is when I need to highlight text for copying and pasting. With mouse support enabled Vim goes into visual mode when you highlight text. Vim supports tab completion! Look at :help ins-completion and the "SuperTab" plugin in the plugins section

and the "SuperTab" plugin in the plugins section You can view your command line history with: q: (when in this window, press Ctrl-c twice to exit)

(when in this window, press Ctrl-c twice to exit) In ex mode you can use a pipe to combine commands (just like a unix shell). The following commands will yank lines 2-4, move to line 7 and put the previous contents of lines 2-4, move to line 4, delete it, and the write the file: :2,4y | 7 | pu | 4 | d | w

View the contents of your registers/buffers: :reg

To repeat a colon command: @: and to repeat it again: @@

and to repeat it again: To view current options: :set

You can also check any individual setting :verbose set ai? - verbose is optional, but it provides additional info (sometimes)

- verbose is optional, but it provides additional info (sometimes) To add a number to each line: :set nu

To turn off numbers: :set nonu - *note: if you are using my advanced .vimrc file, you can use <F2> to toggle line numbers on and off

- *note: if you are using my advanced .vimrc file, you can use <F2> to toggle line numbers on and off To temporarily disable any option: :set no<option> (no space between "no" and the option)

(no space between "no" and the option) To turn off color: :syntax off

Check the version of vim and what was compiled in: :ver

Execute the current file: E or !`pwd`/%

or Execute the current file with an argument: !`pwd`/% arg1

Execute the current file with an argument and piping to more: !`pwd`/% arg1 | more

Temporarily show the line numbers for lines 1-20: 1,20#

Move lines 1-20 to line 51: :1,20m50

Copy lines 1-20 to line 51: :1,20c50

Print the total number of lines of the current file: :=

Gives you a status of: current name of file, your current line number, and percentage of where you are in the file: Ctrl-G

Some of my favorite Vim links

Files

To open up files in other directories, use the full or relative path: :e ../file1 or :e /home/jdoe/file1

or You can also change to a directory and then open it: :cd /home/jdoe

Write the file and quit: :x

Fast way to close and save a file (equivalent to :wq!): ZZ - this is two capital z's

- this is two capital z's Save lines 100 to end of file1 to file2: :100,$w file2

Save lines from 1-50 of file1 to file2 : 1,50w file2

and line 200 to end of file to file3: :200,$w file3

and line 200 to end of file to file3: To undo all of the edits you made in your session: :e!

Open "file" at pattern: vi +/pattern file

Open "file" in read-only mode: vi -R file

Read in file2 and place it: below the cursor: :r file2 after line 50: :50r file2 at end of the current file: :$r file2 at the beginning of the current file: :0r file2

Here are the commands to edit more then one file at a time: From the command line, edit two files: vi file1 file2 Go to the next file: :n Go back one file: :N Go back to first file: :re - short for [re]wind See all the files open and which one you are currently editing: :ar - short for [ar]gs Open a new file named file2: :e file2 Move between files: Ctrl-^ - that is the carrot (^) symbol The percent symbol % is used to represent the current file and # the other file (think of them as shortcuts). For example if you created file1 then did :e file2 then go back to file1, file1 would be % and file2 would be # so if you wanted to read file2 into file1 you would do(there is a space between the r and #): :r #



Here are useful commands when working with files. Note some of these commands talk about editing multiple files at the same time. This is similar, but different then working with multiple windows . Both of them allow you to yank, put, delete, copy between files

Multiple Windows

Edit a file in a new buffer(window): :e filename

Go to next buffer: :bn

Go to previous buffer: :bp

Delete a buffer (close a file): :bd

Open a new blank file in a new buffer and split window (horizontally by default):

Ctrl-w,s or :sp - *Note: you can supply a filename to open that file in the new window

or - *Note: you can supply a filename to open that file in the new window Switch between windows: Ctrl-w,w - *Note: if you are using my advanced .vimrc file, you can use Ctrl-h,j,k,l (navigation keys) to switch between windows. They work just like the navigation keys (ie Ctrl-l to go the left window, etc).

- *Note: if you are using my advanced .vimrc file, you can use Ctrl-h,j,k,l (navigation keys) to switch between windows. They work just like the navigation keys (ie Ctrl-l to go the left window, etc). Quit a window: Ctrl-w,q

Split windows vertically: Ctrl-w,v or :vsp

or Switch/rotate the position of the windows: ctrl-w,r

Make current window larger: Ctrl-w,+

Make current window smaller: Ctrl-w,-

Make windows equal size: Ctrl-w,=

Make current window 10 lines bigger: :res +10 - this stands for [res]ize

- this stands for [res]ize Make current window 5 lines smaller: :res -5

One of the best/coolest/most useful features of Vim is the ability to work with multiple windows in a single Vim session. Here are some of the most useful commands.

Help

Start help: :help - you can also shorten this to :h

- you can also shorten this to There is a html version of the help if you like that sort of thing: Vim Help Online

View the user manual: :help user-manual

To jump to a subject within vim help (subjects are between |bars|): Ctrl-] - *note: if you enabled mouse support (see the first tip in miscellaneous you can go to the subject by double clicking on it with your mouse

- *note: if you enabled mouse support (see the first tip in miscellaneous you can go to the subject by double clicking on it with your mouse To go previous subject: Ctrl-t

Search all of help for "pattern": :helpgrep pattern and use :cn to go to the next match and :cp for the previous one. Use :clist to see all matches in help.

and use to go to the next match and for the previous one. Use to see all matches in help. To go to a specific section of help: :help 10.2 - this will go to section 2 "Substitution" of chapter 10 of the user manual

- this will go to section 2 "Substitution" of chapter 10 of the user manual Help's help (yes Vim's help has a help manual! You know you are dealing with a powerful piece of software when this happens): :help help

Vim has very good built-in documentation, but it can be a bit difficult to navigate. Here are some tips to help:

Keyboard Mappings

Normal: when you first edit a file (that is if you start vi without any command line options)

Visual: when using any of the visual commands

Operator-pending: after you type an operator command (ie. d or y) but before typing the next command (such as w)

Insert: anytime you are inserting text (i, s, or c)

Command-line: when you are in ex mode (by typing a colon ":") or search mode (by typing a forward-slash "/")

map - Normal, Visual, Operator-pending

nmap - Normal

vmap - Visual

omap - Operator-pending

map! - Insert & Command-line

imap - Insert

cmap - Command-line

noremap - Normal, Visual and Operator-pending

vnoremap - Visual

nnoremap - Normal

onoremap - Operator-pending

noremap! - Insert and Command-line

inoremap - Insert

cnoremap - Command-line

Ctrl-x: <C-x>

Shift-x: <S-x>

Alt-x: <A-x>

All of the following are valid for the enter key: <CR>, <Enter>, or <Return> - although <CR> is used the most

Go to the bottom of the file: G

Open a new line below the cursor and enter insert mode: o

Write the word "Date:" Date:

Exit insert mode: <Esc>

Read in the date command and follow it with a carriage return: :read !date<CR> or :r !date

or Move up one line and join the two lines together: kj

In Vim you use keyboard mappings to create keyboard shortcuts. Many people like to map the function keys (F1-F12). Mappings are an extremely useful feature, but the syntax of defining mappings is a bit complicated. Hopefully this section will clarify mappings for you and allow you to create some of your own to do what Vim does best, save you time.To understand Vim keyboard mappings, you have to know the different Vim modes, which are the following:Now that you understand the different modes, it should be clear what the different mapping commands do:You also need to understand the "noremap" command. This basically tells Vim not to look for another keyboard mapping after loading the current one. This prevents mappings from conflicting with eachother. Each mode has their own version:When defining keyboard mappings, you need to know how these common keyboard keys are represented:It is always good to learn from examples. I took the one from Vim's manual and expanded what it does:This will map the <F2> key (in normal, visual, and operator-pending mode) to do the following:For additional help I recommend:

Vimrc Files

Basic vimrc file

Advanced vimrc file & plugins - note, this also includes all of the plugins I discuss below. Just extract it in your home directory. The file is 9.5MB and the MD5 checksum is 2dafe03f745d1014b319308dcd7fe2a6

Here are my two Vimrc files . The basic one is the one that I used for almost 10 years, but as I mentioned in the introduction this past year I set out to see what I was missing and if you compare the two files you will see it was substantial! Both files are commented so they should be pretty much self explanatory.Here are the two files:

Plugins

vim-debug - an integrated debugging environment. Here are some useful links for this plugin: How to install - you need python-pip installed (apt-get install python-pip) Usage - the usage instructions on my Python reference page



snipMate - implements TextMate's snippets features



Usage: you can find a list of snippets (and add your own) in ~/.vim/snippets directory. The default key for snipMate is the <Tab> but this is already being used by Pydiction so I remapped it to <Ctrl>-j to complete the snippet and <Ctrl>-k to list available snippets. You can change this in the ~/.vim/after/plugin/snipMate.vim file. Do a ":help snipMate" and a search on "remap" to see which entries need to be modified. To use snipMate, just type the snippet then type <Ctrl>-j to complete it



Here are some useful python one's: #! - /usr/bin/python wh - while loop fr - for loop cl - new class

Help: :help snipMate







Usage: you can find a list of snippets (and add your own) in ~/.vim/snippets directory. The default key for snipMate is the <Tab> but this is already being used by Pydiction so I remapped it to <Ctrl>-j to complete the snippet and <Ctrl>-k to list available snippets. You can change this in the ~/.vim/after/plugin/snipMate.vim file. Do a ":help snipMate" and a search on "remap" to see which entries need to be modified. To use snipMate, just type the snippet then type <Ctrl>-j to complete it Here are some useful python one's: Help: NERD tree - explore your file system, in the form of a "tree"



Usage: Open NERD tree in the current directory that you are in: :NERDTree Open NERD tree in the /home/jdoe directory: :NERDTree /home/jdoe

Help: :help NERD_tree Also, while in the NERD tree window, type a question mark "?" to bring up the help options







Usage: Help: Also, while in the NERD tree window, type a question mark "?" to bring up the help options Supertab - tab completion on steroids. Allows you to choose your tab completion type (ie. dictionary, file names, tags, etc)



Usage: Begin a tab completion forward: <tab> Begin a tab completion going backwards through the list: <Shift-Tab> Switch the type of tab completion to use: :SuperTabHelp - Note, if you are using my advance vimrc file, SuperTab has "context" based tab completion enabled. This means SuperTab will pick the appropriate type of tab completion (spelling, file names, dictionary, etc.) based on the context of the text.

Help: :help supertab







Usage: Help: Surround - this plugin deals with adding, deleting, and changing parentheses, quotes, and HTML tags



Usage: Remove quotes: ds" - the cursor has to be within the quotes Replace quotes with <q> html tag: cs"<q> - the cursor has to be within the quotes Replace square brackets with parentheses: cs]) - the cursor has to be within the square brackets Add double quotes to the word dog: vlls" - the cursor has to be at the letter 'd' in dog

Help: :help surround





Usage: Help: Taglist - a source code browser plugin. Makes it easy to browse through code. This is the highest rated and most downloaded Vim plugin. Note, you need to have ctags installed (apt-get install exuberant-ctags).



Usage: open/close the taglist menu: :TlistToggle - if you are using my advanced vimrc file, I mapped this to the <Ctrl-y> key. To jump to a tag, double click on it (if mouse support is enabled) or put the cursor on it and hit enter. To move between the Taglist menu and the file you are working with, use <Ctrl-L> and <Ctrl-H>



Help: :help taglist.txt







Usage: open/close the taglist menu: - if you are using my advanced vimrc file, I mapped this to the <Ctrl-y> key. To jump to a tag, double click on it (if mouse support is enabled) or put the cursor on it and hit enter. To move between the Taglist menu and the file you are working with, use <Ctrl-L> and <Ctrl-H> Help: MiniBufferExplorer - this is a very useful plugin. It gives you a mini explorer window for your file buffers.



Usage: this plugin is turned on automatically when you are using buffers (ie. editing more then one file at a a time). You will see a list of the files in your buffer at the top of the screen. Double click with your mouse (if it's enabled) to switch between buffers. If your mouse is not enabled, use <Ctrl-k> to move the cursor to this menu and then <Tab> between each file to go forward and Shift-Tab to go backwards. Also the commands that I have listed for multiple windows are used with this plugin.





Usage: this plugin is turned on automatically when you are using buffers (ie. editing more then one file at a a time). You will see a list of the files in your buffer at the top of the screen. Double click with your mouse (if it's enabled) to switch between buffers. If your mouse is not enabled, use <Ctrl-k> to move the cursor to this menu and then <Tab> between each file to go forward and to go backwards. Also the commands that I have listed for multiple windows are used with this plugin. Command-T - a file explorer for quickly opening any file on your system via Vim. Note, you need to have a version of Vim that has been compiled with Ruby support. If you are running a flavor of Ubuntu (including Mint), then it probably does not have this. You can check with the following command: vim --version | grep ruby and if you see "+ruby" then it does have Ruby support. On Ubuntu/Mint you can install vim-nox which has Ruby support (apt-get install vim-nox). I did this and did not notice any difference between it and the version that came installed with Mint, so I would safe it is safe for you to do this as well. Command-T is a very good useful/plugin and I feel it is worth the small amount of extra trouble.



Usage: Launch Command-T: :CommandT or if you are using my advanced vimrc file: Shift-t . Begin typing the file you are looking for and the list will narrow (note, when you are typing it uses the file OR directory name). If you want to open the file, hit Enter Command-T will search the current directory and all sub directories. If you want to change your parent directory, then do: :cd /parent_dir first If you simply just type the name of the file, sometimes you will not get the match you where expecting especially if it's a common name. To remediate this, type just a few letters of each directory name in the path and then the filename and Command-T will most likely find the correct file. For example, say we have the file test.py in the directory /home/jdoe/python/test/dir/test.py and you are in the /home/jdoe directory, in Command-T all you should need to type is pytedite (the first two characters of each directory and of test.py) for it to choose the correct file. Depending how many directories and files you have with similar names, you may even be able to just type ptdt (the first character of each directory and of test.py). Select next file in the file listing: Ctrl-j Select previous file in the file listing: Ctrl-k Open the file in a new vertical split window: Ctrl-v Exit the Command-T file menu: Esc

Help: :help command-t







and if you see "+ruby" then it have Ruby support. On Ubuntu/Mint you can install vim-nox which has Ruby support (apt-get install vim-nox). I did this and did not notice any difference between it and the version that came installed with Mint, so I would safe it is safe for you to do this as well. Command-T is a very good useful/plugin and I feel it is worth the small amount of extra trouble. Usage: Help: Ack - ack is a faster replacement for grep which also allows you to use Perl's regex engine (very handy). This plugin brings ack's capabilities to Vim. You need to have ack installed (apt-get install ack-grep). I have been using ack and I like it better then grep.





Gundo - this is another very useful plugin. It allows you to see Vim's undo list in a meaningful way. If you every tried to use the comical :undolist command, then you will love this plugin.



Usage:

To toggle Gundo on and off: :GundoToggle - I mapped this to Ctrl-a in my advanced vimrc file When you open Gundo, your current position is the @ symbol. You will see the preview window, that shows what has changed, at the bottom Use the navigation keys j & k to move up and down the tree Move to the bottom of the menu with G and to the top with gg See the difference between the current and selected states: p Revert to the selected version of the file: <Return>

Help: :help gundo







Usage: Help: You can find many more Vim scripts here which is an ordered list of Vim scripts based on their favorable rating and downloads. If you have a favorite plugin that I do not have here, please let me know. I am always looking for good Vim plugins.





These are the plugins that I have installed. They are meant for programmers, but I believe any Vim poweruser will find the majority of them useful. These plugins are all included in my advance vimrc file above . I list the most common commands for each plugin as well as how to get additional help. This is something I have found lacking in other people's discussion of Vim plugins. Sure you can read the documentation, but I find it handy to have a reference for the most used commands and how to get additional help if needed.*Note1: I have another section specifically for Python plugins below *Note2: any where below that hasyou can shorten it to

Vim as Python IDE

Pydiction - allows you to Tab-complete Python code in Vim

Usage: just begin typing some python code and hit tab before entering any whitespace and there will be a popup menu with the available options





Usage: just begin typing some python code and hit tab before entering any whitespace and there will be a popup menu with the available options python_fold - is used to fold/unfold Python code.

Usage: Fold/unfold a single section: f Fold/unfold ALL folds in the file: F Unfold all folds under the cursor: cO - that is a capital letter o Move forward through the folds (does not matter if they are open or not): zj Move backwards through the folds (does not matter if they are open or not): zk

Help: :help fold and :help usr_28







Usage: Help: and Python indent - this is a plugin that provides smart indentation based on PEP8 style guide. There is nothing you need to do. Vim will automatically add the indentation for you.





Pydoc - this plugin allows you to search the Python documentation from within Python.

Usage: Bring up the Python documentation for the regular expression module :Pydoc re Search the documentation for the current word (see :help word for Vim's definition of what constitutes a word) the cursor is on: <Leader>pw Search the documentation for the current WORD (see :help WORD): <Leader>pW



*Note: I have mapped the leader key to a comma in my advanced vimrc file so you would perform the searches with the following keystrokes: ,pw and ,pW

Usage:

I use Vim as my Python IDE. I got the idea from this article among a few others. The plugins that I list above provide many functions of an IDE that can be used in any programming language. Below are a few other plugins that are installed which are Python specific. If you use Vim as your Python IDE and find a plugin very useful that I do not have below, I would appreciate it if you would contact me and let me know. Thanks!