Various Motions: %
The %
command jumps to the match of the item under the cursor. Position the cursor on the opening (or closing) paren and use y%
for yanking or d%
for deleting everything from the cursor to the matching paren.
This works because %
is a "motion command", so it can be used anywhere vim expects such a command. From :help y
:
["x]y{motion} Yank {motion} text [into register x]. When no
characters are to be yanked (e.g., "y0" in column 1),
this is an error when 'cpoptions' includes the 'E'
flag.
By default, "item" includes brackets, braces, parens, C-style comments and various precompiler statements (#ifdef
, etc.).
There is a plugin for "extended % matching" that you can find on the Vim homepage.
You can read the documentation on %
and related motion commands by entering :help various-motions
in command mode.
object-select
There is another set of motion commands that you can use in Visual mode to select various text objects.
To solve your specific problem you would do the following:
printf("%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32)));
^
Let's say your cursor is positioned at ^
. Enter the following sequence to select the part you are looking for:
v2a)
First v
enters Visual mode, then you specify that you want to go 2
levels of parens up. Finally the a)
selects "a block". After that you can use d
or x
to delete, etc.
If you don't want to include the outer parens, you can use "inner block" instead:
v2i)
See :help object-select
for the complete list of related commands.