Learn Essential Vim Skills
with Drew Neil, author of Practical Vim
Ex commands
category applies to 8 screencasts:
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 screencastvimgrep
is Vim’s built-in command for searching across multiple files. It’s not so fast as external tools like ack and git-grep, but it has its uses. vimgrep
uses Vim’s built-in regex engine, so you can reuse the patterns that work with Vim’s standard search command.
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.
For the VimGolf challenge “List the first 100 prime numbers”, there’s a solution that uses a regular expression to detect prime numbers. At 43 keystokes, it’s not the winning solution, but I think it’s the most interesting one. It uses a few clever Vim tricks, including macros, control-a to increment, the very magic pattern switch, and the :global
command. There’s a lot to learn from those 43 keystrokes, so let’s study it!
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 screencastThis episode focuses on the :edit
command. I demonstrate how to open files whose location is relative to the current working directory, then I show how to create a mapping which makes it easier to open files in the same directory as the one in the active window.