Learn Essential Vim Skills
with Drew Neil, author of Practical Vim
search
category applies to 7 screencasts:
The 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 screencastThe *
command searches for the word under the cursor. That makes sense in Normal mode, but from Visual mode it would be more useful if the star command searched for the current selection, rather than the current word. We can add this feature to Vim using the visual star search plugin.
Vim 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.
vimgrep
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.
When you need to build a complex command, or devise a non-trivial search pattern, Vim’s command-line mode can be rather limiting. In this episode, I will introduce the command-line window, which allows you to use the full power of Vim when editing search queries and commands.
Watch screencast