Nicolás Brailovsky


A modern blog

Vim Tip: Know your blocks!

author Posted by: nico on date Jun 5th, 2009 | filed Filed under: Vim, Vim Tips
vim_editor Vim is the best editor for programmers and as such it has some neat “programmer commands”, which make editing source code a lot easier. Take for example a block with code, or a function definition: how many times did you have to copy the code between parenthesis from one place to the other?
  1. int foo(int bar, int baz)

You could do ’0f(df)’ to delete “int bar, int baz” but that won’t do if the definition is more complicated than that. ‘dib’ is a better choice to delete the text.

(ACTION)i{b|B} applies ACTION to a block, for example, pressing diB in

  1. void foo() _ {
  2.         /* Lots of source code */
  3. }

(with the cursor placed at _) will delete lots of source code.

     Add A Comment

trackback Trackback URI | rsscomment Comments RSS