sponsor Vim development Vim logo Vim Book Ad

argtextobj.vim : Text-object like motion for arguments

 script karma  Rating 198/67, Downloaded by 2945  Comments, bugs, improvements  Vim wiki

created by
Takahiro SUZUKI
 
script type
utility
 
description
This plugin provides a text-object 'a' (argument). You can
d(elete), c(hange), v(select)... an argument or inner argument in familiar ways.
That is, such as 'daa'(delete-an-argument) 'cia'(change-inner-argument) 'via'(select-inner-argument).
What this script does is more than just typing
  F,dt,
because it recognizes inclusion relationship of parentheses.

There is an option to descide whether the motion should go out to toplevel function or not in nested function application.

Examples:
  case1) delete An argument
      function(int arg1,    ch<press 'daa' here>ar* arg2="a,b,c(d,e)")
      function(int arg1<cursor here; and if you press 'daa' again..>)
      function(<cursor>)

  case2) change Inner argument
      function(int arg1,    ch<press 'cia' here>ar* arg2="a,b,c(d,e)")
      function(int arg1,    <cursor here>)
      
  case 3) smart argument recognition (g:argumentobject_force_toplevel = 0)
       function(1, (20<press 'cia' here>*30)+40, somefunc2(3, 4))
       function(1, <cursor here>, somefunc2(3, 4))
      
       function(1, (20*30)+40, somefunc2(<press 'cia' here>3, 4))
       function(1, (20*30)+40, somefunc2(<cursor here>4))

  case 4) smart argument recognition (g:argumentobject_force_toplevel = 1)
       function(1, (20<press 'cia' here>*30)+40, somefunc2(3, 4))
       function(1, <cursor here>, somefunc2(3, 4)) " note that this result is the same of above.
      
       function(1, (20*30)+40, somefunc2(<press 'cia' here>3, 4))
       function(1, (20*30)+40, <cursor here>) " sub-level function is deleted because it is a argument in terms of the outer function.
 
install details
just place argtextobj.vim in

Linux: ~/.vim/plugin/ or /usr/share/vim/vim*/plugin/
Windows $VIMRUNTIME/plugin/
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
argtextobj.vim 1.1.1 2009-12-30 7.0 Takahiro SUZUKI debug (stop beeping)
argtextobj.vim 1.1 2009-07-04 7.0 Takahiro SUZUKI support for commas in quoted string (".."), array ([..])
do nothing outside a function declaration/call
argtextobj.vim 1.0 2009-07-04 7.2 Takahiro SUZUKI Initial upload
ip used for rating: 18.226.185.207

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github