Video Tutorials for the Advanced Vimmer

I don't claim to be the most advanced Vimmer on the planet, but I think I know a few advanced techniques. This section is designed to help the intermediate move into the more advanced stage.


The Vim Expression Register

See it straight from Vimeo at The Vim Expression Register.

What we'll cover

The Vim expression register is a really nifty little aspect of Vim that allows for very easy integration of external commands (or even internally defined functions) into the standard text editing process. In this video we take a very simple look at how it can be used to automatically generate and insert a Universally Unique Identifier into your buffer.

  • :help i_CTRL-R_= is the documentation on how to use the Vim expression register.

Vim Autocommands

See it straight from Vimeo at Vim Autocommands.

What we'll cover

Vim autocommands are one of the stronger aspects of Vim's extensibility. Vim allows you to hook in to events that occur in the system, such as just before a buffer is written (:help BufWritePre) or when the cursor is moved (:help CursorMoved). You can hook in to these events for particular file types or file extensions and have code run that does whatever sexy bit of work you need done.

  • :help :autocmd is the documentation for the autocommand feature of Vim.
  • :help :augroup details the structure you can use to group autocommands together. I generally recommend that you always do this as deleting autocommands isn't necessarily possible but is very easy using groups.
  • :help :function teaches the important bits you need to know to start writing a function.

Find Command and the Path

See it straight from Vimeo at Find Command and the Path.

What we'll cover

Vim gives the ability to load up a file from locations that you specify in a search path. Much like the PATH variable in Windows or the Unix command shell, Vim has a path system that can do the same sort of thing, but for files instead of exectuables.

  • :help :find discusses the find command and what it does.
  • :help 'path' is the option that allows you to specify where Vim should look for your files.
  • :help :autocmd is the documentation for the autocommand feature of Vim that we use to run a function that sets the 'path' for us.
  • :help :augroup holds our autocommands.
  • :help expand()) is extremely useful for expanding special filenames and manipulating path strings.

Globals, Commands and Functions

See it straight from Vimeo at Globals, Commands and Functions.

What we'll cover

This is all command-line mode stuff; even the normal mode commands are going to be issued via the command-line. What we're going to do is take an XML document and strip away the XMLiness of it and make it a standard text file that we can deal with. And we're going to do it without using a single insert-mode command. Rock 'n Roll!

  • :help :g tells you all about the :global command, which is an extremely powerful command-line tool.
  • :help :v tells you that it's the inverse of the :g command.
  • :help :s talks about the substitute command... oh so powerful.
  • :help :/\( is the aspect of regular expressions we use to create subgroups that are remembered.
  • :help /^ is the way we anchor a regular expression to the beginning of a line.
  • :help /\{ describes how to put "counts" into regular expressions so we don't have to repeatedly enter characters; we just say how many times they repeat.
  • :help /[] lets us specify a collection of characters. Sometimes that collection is merely a collection of things that are "not" something else, which is denoted by [^.
  • :help /\zs lets us make a more specific "start" to a regular expression with respect to its substitution - very cool.
  • :help :normal lets you execute normal-mode commands from the command-line.
  • :help :t tells you about the synonym for the "copy" command.
  • :help search-pattern is a very long and very important section on how to use regular expressions in Vim. Study.