Editing text

category applies to 15 screencasts:

Run time:

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 screencast
Run time:

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.

Watch screencast
Run time:

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 screencast
Run time:

The :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 screencast
Run time:

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.

Watch screencast
Run time:

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.

Watch screencast
Run time:

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.

Watch screencast
Run time:

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 screencast
Run time:

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 screencast
Run time:

HAML 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 screencast
Run time:

Recording 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 screencast
Run time:

Vim’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 screencast
Run time:

Demonstrating 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 screencast
Run time:

This episode covers the commands for shifting text left and right (< and >), and also goes over the auto indent command (=).

Watch screencast
Run time:

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