views:

50

answers:

1

hello, I am new to UNIX programming and had the following problem with UNIX vi editor.

Can you please tell me the UNIX command required to delete text delimited by { and } where both characters occur after the current cursor position. Thanks.

+3  A: 

If you're on the same line :

f{d%

f{ moves you to the next { character d% deletes everything to the matching bracket

If you're on a different line, use /{ to search for that character

And if you want to delete ALL text delimited like this :

:%s/{.*}//g

(replaces all instances of anything between brackets with nothing)

Matthieu
Thanks a lot for your answer. when I type in :%s/{.*}//g it says, "E486: Pattern not found: {.*}". and it suppose to delete things that occurs after the current cursor position and shouldn't delete the ones above. in a separate book I found the following as a HINT. follow the pattern search with the terminating / and use a + after the /. Thanks.
I think the problem with the pattern not found may be if there are new lines between the brackets... I am not able to find a good solution for that...
Matthieu
Thanks a lot for the help.