On Wed, 28 Oct 2009 19:36:01 +0900, Raúl Núñez de Arenas Coronado 
<[email protected]> wrote:
> Hi all :)
>
> I use Vim to store lists of items, like the one below:
>
> - This is a think I should do, or maybe buy
> - Feed my cat
> - Tell my cat he is a naughty boy for having chewing up my most
>   expensive headphones without having even considered the possibility of
>   eating a cheaper pair (or none).
> - Write a message to vim_use to ask how to delete items from lists like
>   this, where some of the items are oneliners but others are clearly
>   not, and may or may not have a final period
> - More items, this time an oneliner
> - Stop using computers. NOW!

...

> I wondered if I could use some text-object to perform this action (maybe
> changing the "dash" for another character) or some more complex command
> which I could map, whatever, and being able to cut or copy an entire
> item automatically, without having to go to the start of the item, not
> having to count lines, etc. I know how to do this using vimscript and a
> loop, but I wondered if a simpler approach exists.

Try textobj-user <http://www.vim.org/scripts/script.php?script_id=2100>.
With textobj-user, what you want can be written as follows:

call textobj#user#plugin('item', {
\   '-': {
\     '*pattern*': '^-\(\s\+\).*\(\n\s\1.*\)*\n',
\     'select': 'I',
\   },
\ })

Then you can edit an item with dI, yI, etc.


-- 
To Vim, or not to Vim.
http://whileimautomaton.net/


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to