Skip to content

amadanmath/Parameter-Text-Objects

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

This is a mirror of http://www.vim.org/scripts/script.php?script_id=2979

This script defines a parameter text object. A parameter is the text between
parentheses or commas, typically found in a function's argument list.

See:
:help text-objects
  for a description of what can be done with text objects.
Also See:
:help a(
  If you want to operate on the parentheses also.

Like all the other text-objects, a parameter text object can be selected
following these commands: 'd', 'c', 'y', 'v', etc. The script defines these
operator mappings:

   aP    "a parameter", select a parameter, including the preceding comma
         (if there is one).

   iP    "inner parameter", select a parameter, not including commas.

If you would like to remap the commands then you can prevent the default
mappings from getting set if you set g:no_parameter_object_maps = 1 in your
.vimrc file. Then remap the commands as desired, like this:

   let g:no_parameter_object_maps = 1
   vmap     <silent> ia <Plug>ParameterObjectI
   omap     <silent> ia <Plug>ParameterObjectI
   vmap     <silent> aa <Plug>ParameterObjectA
   omap     <silent> aa <Plug>ParameterObjectA

By default, aP on the first parameter will not include a comma. This
will make it behave just like iP in this special case.

The behaviour in the previous version of this plugin was that aP must
always capture at least one comma: in this way, if you delete a
parameter, you will always end up with correct code (i.e. no extra
commas). However, this is inconsistent with the behaviour of aP in
non-first parameters in that the comma is sometimes at the beginning
of the text-object (non-first parameters), and sometimes at the end
(first parameters). This behaviour can be switched on by setting
g:parameter_objects_force_comma.

This is a slick version of argtextobj vimscript #2699; though mine is shorter and can handle counts (ie. c3aP).

NOTE: Negative ratings don't help the script to improve. Instead, please send me an email (shown in my profile). Thank you.

Packages

No packages published

Languages

  • Vim Script 100.0%