1

I have a file listing all the books I have read since 2013. I told someone I read x books a week and they didn't believe me so I started doing it :)

The data looks like this. The last column is the count of books read. I have a function that renumbers the entries as they may be read years apart.

Start: 1 Aug 2013

%Daniel Silva Spy Isralie% !Gabriel Allon Series! The Rembrandt Affair Year 2013 1 The Secret Servant Year 2013 2 Moscow Rules Year 2013 3 The Defector Year 2013 4 The Messenger Year 2013 5 Prince of Fire Year 2013 6 Portrait of a Spy Year 2013 7 The Fallen Angel Year 2013 8 The English Girl Feb 2019 9

Being clumsy fingered I miss the tab between the year and the count sometimes so I have this search \v^\s+\S to check that the count from the search matches the last count at the document end. That worked until I hit > 1000 books this year. Can I get a count of pattern matches where the count is > 1000 some other way?

Result of pattern match

Rich
  • 31,891
  • 3
  • 72
  • 139
Steve
  • 276
  • 1
  • 13

1 Answers1

2

You can use the :s[ubstitute] command's n flag. As described under :h count-items:

To count how often any pattern occurs in the current buffer use the substitute command and add the 'n' flag to avoid the substitution.

So...

:%s/\v^\s+\S//n

Or if you've already searched for the pattern you could, of course, just do...

:%s///n

Either way, this handles counts higher than 1000.

B Layer
  • 19,834
  • 2
  • 30
  • 57