Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

up vote 3 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.