Saturday, May 28, 2011

Re: delete inside parentheses VIM?

On 29/05/11 05:11, Antonio Recio wrote:
> "dab" it is useful to remove parentheses and content when cursor is
> over, I think. But I want to delete all the parentheses and the inside
> the parentheses with an unique commmand.
>
> --
> 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

dab (which is a single command; you could also use da( or da) ) works
with the cursor anywhere between the ( and ) inclusive; if there are
nested parentheses it will delete the innermost () block containing the
cursor: example: (where ^ marks the cursor location and - what is
deleted; please view this in a fixed font)

aaa(bbb(ccc(ddd))efg)
--^---------------
-^--------
--^--
--------------^---

IIUC, when used with a count (i.e., d2ab d3ab etc.) it will delete that
many nested blocks containing the cursor.


To delete from the first ( to the last ) on a line you could use
:s/(.*)// but with no guarantee that those brackets will be matching
ones; or you could place your cursor on one of the brackets and use d%
to delete everything up to its mate (inclusive).


Best regards,
Tony.
--
The Soviet pre-eminence in chess can be traced to the average Russian's
readiness to brood obsessively over anything, even the arrangement of
some pieces of wood. Indeed, the Russians' predisposition for quiet
reflection followed by sudden preventive action explains why they led
the field for many years in both chess and ax murders. It is well
known that as early as 1970, the U.S.S.R., aware of what a defeat at
Reykjavik would do to national prestige, implemented a vigorous program
of preparation and incentive. Every day for an entire year, a team of
psychologists, chess analysts and coaches met with the top three
Russian grand masters and threatened them with a pointy stick. That
these tactics proved fruitless is now a part of chess history and a
further testament to the American way, which provides that if you want
something badly enough, you can always go to Iceland and get it from
the Russians.
-- Marshall Brickman, Playboy, April, 1973

--
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

No comments:

Post a Comment