Topic “Vim”

VIMDIFF - use Vim for diffing

vimdiff -O file1.php file2.php

Open two files in Vim in vertical spilt screen mode (-O) with scrollbinding and diff highlighting on.

Select text/code inside braces, brackets, quotes, etc. in Vim

Let's use the following code as an example...

if ($is_true) {
  $value['mes|sage'] = 'Excellent spare ribs, Martha!';
  $value['type'] = 'compliment';

And let's say our cursor is that pipe between the two s's in 'message,' above.

Press v to enter visual mode, and then follow that with one of the following


to select text all code within the curly braces. In this case, that's the two $value assignment lines.


will select the word "message," as it is inside 's.

Clear contents within (parentheses ) [braces ] and {curly braces}

In Vim, given code such as

if ($check) {
  echo $array['true'];

If you're on or within the parentheses and enter


you'll clear the $check out of there.

Same goes for


which would clear the 'true' out of the $array brackets.



would wipe away all the contents of the curly braces.

Syndicate content

Find Me Around

User login