Saying that I have such a file as below:


I want to remove the first square bracket and its content so that the file becomes:


How could I achieve this?

I've tried to execute :%s/<.*>// but it will remove all things I think it's because it matches the last > for each line.


1 Answer 1


I guess this would be the easiest solution:


It matches:

  • < an opening angle bracket
  • [^>]* anything not being a closing angle bracket
  • > a angle bracket.

Of course the other solution is to use a non greedy operator as in the question linked by @Mass like this:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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