Friday, September 27, 2013

Re: Wishlist item: comma object-selecting motion

On Fr, 27 Sep 2013, Codie Codemonkey wrote:

> Object selections have become one of my favorite Vim features. (See :help object-select for some context for this request.) It took me awhile to discover them, but now that I have I use them constantly.
>
> I'd like to see a new one (or actually two considering the a and i forms) to select comma separated items in a list.
>
> In the simplest use case, comma object selection would include text starting at the previous comma or '(' to the next comma or ')'.
>
> a, - Select the current parameter in a C-style parameter list. Any previous whitespace will be included, as well as any trailing ','. Whitespace after the trailing ',' will not be included. If the parameter is the last in the parameter list, the ending delimiter will not be selected.
>
> i, - Same as a, except that leading whitespace and a trailing ',' (if present) will not be part of the selection.
>
> Other bracketing delimeters should work in addition to '(' and ')', including '[' and ']', '{' and '}' and possibly '<' and '>'.
>
> Examples:
>
> Consider this line of programming code:
> func( a, b(c, d[0]), "this, is a test")
>
> In normal mode with the cursor on the first parameter, "da," would change this to:
> func( b(c, d[0]), "this, is a test")
>
> Or, if the cursor is on 'b' in the second parameter, "da," would yield:
> func( a, "this, is a test")
> (Note the ignored ')' and ']' characters.)
>
> Or if the cursor was in the string of the third parameter, "da," would yield:
> func( a, b(c, d[0]), )
> (Note that the ',' in the string was not a delimiter because it was nested between quotes.)
>
> Some filetypes have other needs. For example in a CDF file, <C-R> is a bracketing character. To accommodate this I suggest some accompanying options:
>
> listsep - Characters used to separate items in a list. Default: ',;'
> liststart - Characters used to start a list (if not nested in quotes or balanced bracketed strings). Default: '({[<'.
> listend - Characters used to end a list (if not nested in quotes or balanced bracketed strings). Default: ')}]>'.

This is probably already implemented using some plugin. I just recently
stumbled over thisน, but haven't used it, so this might or might not do
what you want.

น)https://github.com/kurkale6ka/vim-pairs

Best,
Christian
--
Marionetten lassen sich sehr leicht in Gehenkte verwandeln. Die
Stricke sind schon da.
-- Stanislaw Jerzy Lec (eig. S. J. de Tusch-Letz)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment