Vim Tips 1 — Visual Block Change

I’ve been enjoying sharing my tips with you all on Twitter lately, so I’ve decided that I’ll try and post more visual, video-based, Vim Tips on a regular basis … I’d say daily, but I don’t want to commit just yet :)

Same Change; Multiple Lines

Do you ever need to change / insert text on the same position on more than one line? It’s pretty common when writing code.With Vim, we can accomplish this task with Visual Block editing.

Here’s an example:

# My init.vim (vimrc, but Neovim)
set showmatch
set ignorecase
set smartcase
set smarttab
set hlsearch
set incsearch

Lets assume I want to change these six set's to my new phrase, for the giggles, right?

# Enter Visual Block
Control-V
# Make your selection
5-DownArrow 2-RightArrow
# Or 5j2l ... if you hate your arrow keys :)
# Chose your action, for us C (Change)
C
# Insert new word / phrase
my new phrase
# Change whole block
ESC