0

I have a very large table covering many pages in a document. The same footnote appears under the table on every page and I want to strip the entire document of these lines so I'm left only with the table. Imagine there are 3 footnotes like this:

This is a footnote
Another footnote
Yet another footnote

It seems I can delete the first footnote with :g/^T/d, and delete the 2nd with :g/^A/d, etc. But is there some way to tell vim to delete any line starting with T or A or Y in a single command?

It might seem unwise to run the command above over the entire document but the table is full of numbers and I know there are no other lines beginning with a letter aside from those in the footnote.

I checked the vim book by Robbins, Hannab & Lamb and couldnt see that it was possible. Can I assume an experienced vim user would simply type : and then use the arrow keys to recall the previous command and change the one letter, and repeat this for the number of lines in the footnote?

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65
neverdimed
  • 97
  • 6
  • To answer the last question, I highly doubt an experienced vim user would use :<up> to change a single letter for every single footnote line :) In fact, if you know they all have a format like 1., you can do something like :global/^\d\. /delete – D. Ben Knoble May 16 '22 at 16:20

2 Answers2

1

I think I found the answer, p75 Robbins, Hannab & Lamb: [] means "match any one of the characters enclosed between brackets."

So I would do:

:g/^[TAY]/d
D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65
neverdimed
  • 97
  • 6
1

More generally, see :help {pattern}. For more complex patterns, you might want alternations (/^\(T\|A\|Y\)/) or concats.

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65