Learn Essential Vim Skills
with Drew Neil, author of Practical Vim
Editing text
category applies to 15 screencasts:
Swapping two regions of text is a common task, which normally requires that we make two separate changes to the document. Tom McDonald’s exchange plugin offers an elegant alternative, by providing an operator that swaps two regions of text in one go.
Watch screencastThe gn
command (introduced in Vim 7.4) makes it easy to operate on regions of text that match the current search pattern. It’s especially useful when used with a regex that matches text regions of variable length.
The abolish plugin provides a command called :Subvert
, which is like a supercharged version of Vim’s built-in :substitute
command. The :Subvert
command is especially useful for changing singular and plural variants of a word, and for refactoring names that appear in snake_case
and MixedCase
.
This is part two of a three-part series on Tim Pope’s abolish plugin.
Watch screencastThe :Subvert
command lets us create a particular style of regular expressions with ease. It’s great for matching irregular singular and plural words in plain English and also for variable names that come in snake_case
and MixedCase
forms.
This is part one of a three-part series on Tim Pope’s abolish plugin.
Watch screencastVim doesn’t have a built-in command for project-wide find and replace operations, but we can perform this task by combining primitive Ex commands such as :substitute
, :argdo
, and :vimgrep
. We’ll look at two possible strategies: first using the arglist, then the quickfix list.
The :argdo
command allows us to execute an Ex command across all buffers in the arglist. To demonstrate, we’ll use the example of running the :substitute
command across multiple files, then we’ll see how to revert or save the changes. We’ll also compare the :argdo
and :bufdo
commands, and consider when it’s appropriate to use each one.
When writing code, we can often save time by duplicating a line then changing one or two parts of that line to make it suit our purposes. In this episode, we’ll compare a few techniques for duplicating lines, and we’ll see that the :copy
Ex command is well suited to this task.
There are times when you can improve the readability of your code by lining up the elements on neighbouring lines. In this episode, I demonstrate how this can be achieved using the Tabular plugin.
Watch screencastBubbling text
#26
TextMate has a few built in commands for moving selected text around a document. The end end result of using these commands can be achieved by cutting and pasting, but the visual feedback they provide is quite helpful. In this episode, I will show how to replicate these commands in Vim.
Watch screencastHAML and ERB are two commonly used ruby templating languages. You may have a strong preference for one or the other, but it’s not always up to you which one you use. I was recently asked to convert several HAML files to ERB format. In this episode, I will demonstrate a couple of Vim macros that helped make short work of the task.
Watch screencastRecording your keystrokes as a macro can be a great timesaver, but you have to be careful that you use commands in such a way that they can be reused. In this episode, I construct a fairly complex macro to build a structural HTML document from markdown.
Watch screencastVim’s modal editing paradigm - the newbie killer - brings tremendous efficiency if only you can learn to work with it, rather than against it. This episode demonstrates how the undo and repeat commands can benefit from spending short bursts of time in insert mode.
Watch screencastDemonstrating miscellaneous tips and tricks gleaned whilst making an ASCII art version of the VimCasts.org logo. Learn how to duplicate lines, copy and paste with visual block mode, search and replace within a visual selection, and how to use macros.
Watch screencastThis episode covers the commands for shifting text left and right (<
and >
), and also goes over the auto indent command (=
).
This episode demonstrates a few techniques for tidying up whitespace. First, it looks at how to convert between tabs and spaces. Then it shows how to strip trailing whitespace, and finally, how to remove blank lines from a file.
Watch screencast