Search code examples
vim

How do you select the entire PHP function definition?


In PHP, if I have a function such as:

function test($b) {

  var $a = 0;

  while ($a < b) {
    $a += 3;
  }

  return $a;
}

and the cursor is on the $a += 3 line, is it possible to quickly select the entire function?

"v2aB" would select everything including the function braces but not the declaration function test($b)


Solution

  • Press V after the selection command you post, to convert the selection to line selection, and it will select the function declaration:

    v2aBV