Vim: Useful text objects and motions

Flashcard 1 of 7

What's the quickest way to delete the entire foo method, given your cursor position:

def baz
  qux
end

def foo
  bar
end

def blag
  blarg
end

dap gets it done in three keystrokes.

  1. d - delete (note: the delete command waits for a subsequent motion or text object)
  2. ap - a paragraph (a sequence of lines surrounded by a newline)

:h ap describes the "a paragraph" text object.

Return to Flashcard Results