Vim: Useful text objects and motions

Flashcard 7 of 7

How can we delete this if / end pair and everything inside it?

def foo
  if bar
    # blah
    # blah
    # blah
    # blah
  end
end

d% will do it.

  1. d - delete
  2. % - until the matching end

As you might guess, :h % will tell you more.

Note: this behavior requires that you enable vim's built-in matching plugin like so: runtime macros/matchit.vim.

Return to Flashcard Results