Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do vim or gVim commands exist to copy text between parentheses?

Tags:

vim

In the following code snippet, if I go to the first open parenthesis ( of the line beginning with (spit

(defn missing-accts 
    "Prints accounts found in one report but not the other."

    [report-header mapped-data out-file]
    (spit out-file (str "\n\n    " 
          (count mapped-data) 
          "   " report-header 
          "\n\n") :append true)
          .
          .
          .

vim highlights the first ( and closing ) parentheses.

Is there and, if there is, what is the vim command that would yank the entire spit command?

Thanks.

like image 202
octopusgrabbus Avatar asked Dec 01 '22 22:12

octopusgrabbus


1 Answers

The sequence

va(

will highlight from the opening to closing brackets inclusively, and a y will then yank that. Note unlike the % command, you don't have to be positioned on the bracket - you just need to be inside the clause.

Note that

vi(

would highlight everything inside the brackets, but not the brackets.

You can do this for braces too ({ instead of () and XML tags (t - presumably for tag)

like image 91
Brian Agnew Avatar answered Dec 18 '22 15:12

Brian Agnew