Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


hpr1091 :: Useful Vim Plugins

Some of the Vim/gVim plugins I use and would like to recommend

<< First, < Previous, Latest >>

Host Image
Hosted by Dave Morriss on 2012-10-05 is flagged as Explicit and is released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. | Comments (1)

Useful Vim Plugins

I started learning vi a long time ago when I first encountered Unix systems. In those days you could usually count on a system having vi (or at a pinch, when the system would only boot into single user mode, ed). Learning Emacs didn't seem like a good choice since it wasn't usually available on the systems I was administering.

I don't remember when I changed to Vim, but for many years I have used it (actually gVim) as an IDE (Integrated Development Environment), particularly for writing Bash and Perl scripts.

In these notes I have listed some of the plugins I use to enhance Vim and gVim's functionality. If you have never made enhancements to this editor, here's a site with a very good tutorial on how to install plugins http://www.installationwiki.com/Installing_Vim_Scripts.


NERDTree

This plugin provides a file browser within Vim/gVim. A particular directory is opened by typing :NERDTree somedir. A tree is displayed in a window which can be scrolled and traversed to find files to edit.

In case you're interested, the colour theme I use in gVim is "Murphy".

Type :h NERD_tree for the large and comprehensive help file.

I prefer to use NERDTree in gVim and not in Vim. To achieve this I have the following in my ~/.vimrc

  " NERDTree settings (only in GUI mode)
  if has("gui_running")
      let NERDTreeRoot = '~'
      let NERDTreeIgnore = ['\~$', '\.swp$']
      let NERDTreeShowHidden = 1
      let NERDTreeShowBookmarks = 1
      let NERDTreeChDirMode = 2
  else
      let loaded_nerd_tree = 1
  endif

Bash-support

This one provides a Bash scripting IDE for Vim and gVim. I find it most usable in gVim where it offers a comprehensive set of menus which you can see in the example.

From the Help text:

  It is written to considerably speed up writing code in a consistent style.
  This is done by inserting complete statements, comments, idioms, and code
  snippets. Syntax checking, running a script, starting a debugger can be done
  with a keystroke. There are many additional hints and options which can
  improve speed and comfort when writing shell scripts.

The plugin can be used from the menu or by typing short-cut sequences such as \ct which inserts the current date and time at the cursor position. It's an amazingly detailed package that's well worth dedicating the time to learn if you often write Bash scripts.


Perl-support

This plugin provides a Perl scripting IDE for Vim and gVim. As with the Bash plugin from the same author I find it most useful from gVim where the menus can be used to perform a wide range of actions.

Again, you can use it to insert statements, boilerplate text and comments, in a similar way to the Bash plugin. You can also get regular expression help, check, run and debug the script

Two of the functions I find particularly useful are perltidy and perlcritic. Perltidy will reformat your Perl script, and Perlcritic will critique it according to the rules based on Damian Conway's book Perl Best Practices.

Note the lower window showing the various problems detected by perlcritic.

If you are a C or C++ programmer Fritz Mehner also provides a plugin for these languages here.


manpageview

This is a man page viewer for use within Vim. Use :Man topic or press K on a keyword. Can view perl, php and python help.

This is a great way to view man pages, with the ability to search and cut and paste the contents.


Surround

The plugin provides mappings to easily delete, change and add "surroundings" such as quotes, braces and parentheses.

The following extract from the Help text should make this clearer:

  Consider the following examples.  An asterisk (*) is used to denote the cursor
  position.
  
    Old text                  Command     New text
    "Hello *world!"           ds"         Hello world!
    [123+4*56]/2              cs])        (123+456)/2
    "Look ma, I'm *HTML!"     cs"<q>      <q>Look ma, I'm HTML!</q>
    if *x>3 {                 ysW(        if ( x>3 ) {
    my $str = *whee!;         vlllls'     my $str = 'whee!';

Fugitive

A very powerful interface to git.

The image shows the result of the :Gstatus command which is equivalent to typing git status on the command line.


Taglist

This plugin provides source code browsing by listing tags (functions, classes, structures, variables, etc.). The list is in a window in Vim or in a menu in gVim.

The plugin makes us of the Exuberant Ctags utility to index tags in a source file. I believe that most Linux distributions ship with this utility, but if not it seems to be easily available in repositories.

The image shows gVim with the tag list in a window. I find the menu in gVim more useful myself.


Supertab

Provides insert completion functionality using the Tab key.

The example shows a Perl script where the choice being made from the list offered by Supertab is uptodate. Note also that manpageview is being used to view the manpage for the CPAN module.

It has taken me a while to learn not to use the Tab key to enter TAB characters but to use CTRL-Tab instead. However, I have decided that the advantages of redefining the Tab key in this way outweigh the disadvantages. You might not agree!


Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2012-10-25T11:53:45Z by klaatu

great info

Hey, thank you so much for this episode. I have long wanted to beef up my vim installs. It seems, somehow, that emacs so famously does that, and yet no one in the vim world seems to talk about it all that much, so i was really struggling to find the good plugins for vim.

This episode was exactly what i needed! thanks!

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to
record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?