Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is the text:

It is the text outside the bracket. {I am some text in the backet.} This is another text outside the bracket.

I wanna to remove the {} inside the text. So, I f{ and x it, and f} then x it again.... is there any easy method for me the delete the bracket? Thanks.

share|improve this question
    
Why not just find all the brackets and replace them with empty string? (Sorry, but it's not very clear what you're trying to achieve here.) – ADTC Feb 15 '12 at 8:26
up vote 4 down vote accepted

put your cursor to block

f{

yank inner block

yi{

select entire block

va{

overwrite selected block

p


Note: It works on multi-line block.

share|improve this answer
    
Very nice. Takes care of nesting, multiline, etc. If the poster does this a lot, just map it to a key. – Daniel Andersson Feb 16 '12 at 9:36

Well, depending on "easy", but

:s/{\([^}]*\)}/\1/

Use with modifiers in regular order to handle multiple replacements per line, etc.

On a single bracket pair, this is more work than your manual example, but if it concerns many replacements it saves time.

EDIT: the difference between this and searching for all brackets and removing them (:s/[{}]//) is that this only removes balanced brackets, but with some quirks (nesting, as I mentioned).

"What am I really trying to do?" is almost always worth explaining in a question to get better answers.

share|improve this answer

Here's yet another way, and like kev's answer, it works on multi-line blocks and respects nesting braces.

Move your cursor to the block:

f{

Jump to other end:

%

Delete brace at the end:

x

Jump back to where you started (these are backticks):

``

Delete brace at the beginning:

x

Here it is altogether:

f{%x``x

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .