Video Tutorials for the Intermediate Vimmer
In truth, categorizing things into Novice, Intermediate and Advanced is kinda tough… Intermediate is the worst one :) These are just the things that aren’t necessarily Novice and aren’t necessarily Advanced.
- The vimrc File and Vim Runtime Directories
- Vim Modes Introduction
- Insert Mode
- One Vim… Just One
- Destruction is Good
- Using a Vim Macro to Edit Many Files
- Vim Macros and Global Commands (one)
The vimrc File and Vim Runtime Directories ==========================================
See it straight from Vimeo at The vimrc File and Vim Runtime Directories.
What we’ll cover
We’re not really covering keystrokes or commands in this one - we’re covering concepts behind Vim’s configuration and extensibility. This is important stuff to understand in order to truly make Vim your own personal editor. The topics you should read up on are:
Vim Modes Introduction ======================
See it straight from Vimeo at Vim Modes Introduction.
What we’ll cover
Modes are what set Vim apart from everything else so it’s about damn time we started looking at them. This video merely introduces them and ensures we have the right terminology laid down.
- :help vim-modes
- :help Normal-mode
- :help Visual-mode
- :help Insert-mode
- :help Command-line
- :help Ex-mode
See it straight from Vimeo at Insert Mode.
What we’ll cover
Insert Mode is one of those often-used modes. You use it all the time to input text - althought one should probably be trying to figure out how to use Insert Mode as little as possible since entering text is inefficient. Insert mode provides us with a few tricks to help us insert more efficiently and we’ll be covering a few of them now. As always it’s simply not possible to cover all the possibilities, so you’re more than encouraged to read through the documentation.
- :help insert.txt
- :help usr_24.txt
- :help ‘textwidth’
- :help i_CTRL-T
- :help i_CTRL-D
- :help i_CTRL-W
- :help i_CTRL-V
- :help ins-special-special
- :help ins-completion
- :help ‘complete’
- :help i_CTRL-N
- :help i_CTRL-P
One Vim… Just One ===================
See it straight from Vimeo at One Vim… Just One.
What we’ll cover
This one’s about running one GUI Vim session and commanding it from an external command shell using the command “gvim --remote-silent
” from that external command shell.
Destruction is Good ===================
See it straight from Vimeo at Destruction is Good.
What we’ll cover
In this video we’re going to look at an editing technique that involves getting to where you want to be by destroying contents, not by creating them. The idea here is that we want to “copy” a few lines from a file and “paste” them somewhere else so we can work with them. It turns out that doing such a thing is usually very annoying and not very productive, so instead of doing that we destroy the contents of the file that we don’t want and keep the rest.
- :help :vglobal shows us how to perform an operation on all lines that don’t match the given pattern. In this case we delete lines that don’t match what we’re looking for.
- :help :substitute shows us how to substitute one piece of text for another. In this case we’ve given it a range of ‘%’ that is synonymous with a range of “1,$” (:help :%).
- :help regexp is a reference to regular expressions. These are very complex things but considering that I used them, I figured I’d point you at them. If you aren’t familiar with regular expressions, stay tuned… we’ll be covering them eventually.
Using a Vim Macro to Edit Many Files ====================================
See it straight from Vimeo at Using a Vim Macro to Edit Many Files.
What we’ll cover
In this video we show how to use a cleverly crafted Vim macro to do a pretty cool edit to some C++ source code across a lot of different header files. The general trick is to avoid “position oriented” kind of things, such as “move down to the next line ‘cuz that’s where the function is” because in the next file, the function may be two lines down.
- :help q is how we record a macro. It’s used for both starting and stopping the recording.
- :help yank is somewhat synonymous with (crappy) Notepad’s
File->Copy
“feature”. - :help % is the operator we use to move the cursor to the brace that is the partner of the one that the cursor is currently on.
- :help / is what let’s us search for things in a file.
- :help O opens a line above the cursor.
- :help p let’s us put (paste) the text that we previously yanked.
- :help :wnext is the command we use to both write the current file and move on to the next one in the :args list.
- :help @ lets us run the macro that we recorded.
Vim Macros and Global Commands (one) ====================================
See it straight from Vimeo at Vim Macros and Global Commands (one).
What we’ll cover
Here we edit a file using two different methods - a recorded macro and a global command.
- :help CTRL-A increments the first number it can find on the line (by one or an optional argument).
- :help q is how we record a macro. It’s used for both starting and stopping the recording.
- :help @ lets us run the macro that we recorded.
- :help :global is how we can run a given command (in this case a :normal command) for each line that matches a pattern.