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.

In Vim, I'd like to search for lines with a given string, then delete them.

Specifically, I'd like to find lines with the LaTeX commands \begin{frame} and \end{frame}, and delete them. =

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Yes.

Use the g command to operate on lines matching a pattern, along with the d command to delete those lines.

g/pattern/d

So:

g/\\\(begin\|end\){frame}/d

should do the trick.

If that doesn't work, try:

:g/\v\\(begin|end)\{frame\}/d

which will work, no matter what your magic setting is.

share|improve this answer
    
Thanks! The g is the trick I needed to learn! –  Richard Herron Feb 23 '11 at 21:04
add comment

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.