I have a file that contains a bunch of strings such as:

xx10 , xx11, xx12, xx13, ..... , xx1183

I want to find out which of these 1183 strings are NOT in the file.

Is there a way to do this in vim ??

Assuming that the "xx" portion is constant across each line (instead of a regexp you're eliding), I'd do it by searching for each pattern and building a list of those that don't match:

:let lst=[] | for i in range(1,10)| if (!search('xx'.i.'\>')) | call add(lst, i) | endif | endfor

The value in "lst" will contain the missing indexes. For huge volumes of data, this is inefficient as it searches the whole document for each match. But for a mere thousand-and-change, it should be fine. If the gaps would only ever be one missing number, and never more-than-one, other fairly simple manipulations could be done for larger data-sets. Otherwise, I'd change to a full-fledged script (I'd use Python or awk since they're my hammer of choice, but others might reach for perl, ruby, or vim-script).

-tim



--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to