3

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. =

1 Answer 1

5

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.

1
  • Thanks! The g is the trick I needed to learn! Feb 23, 2011 at 21:04

You must log in to answer this question.

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