On Feb 4, 11:38 am, drlatex <[email protected]> wrote:
> Hello,
>
> Is it possible for vim to search for repeated strings in a document ?
>
> For example, the file:
>
> abc
> def
> 123
> 654
> bcd
>
> has no repeated strings,
>
> But the file:
>
> 1234
> 2345
> 1567
> 1234
> 3214
>
> has the redundancy on lines 1 and 4.
>
> This might be hard because in the first file, the string 'bc' is in fact
> repeated on lines 1 and 6, but I am looking for if the file has two lines
> that are redundant.
The following is rough, but could give you an idea for one possible
approach...
:let dict = {}|let arr = []|g/^./exe "if has_key(dict, getline('.'))|
call add(arr, line('.'))|endif|let dict[getline('.')] = 1"
After executing the command above, the line numbers of redundant lines
should be in array "arr".
Hope it helps...
Brett Stahlman
>
> Any help, suggestions or discussion is greatly appreciated,
>
> Thank you!
> --
> View this message in
> context:http://old.nabble.com/search-for-repeated-string-tp27456713p27456713....
> Sent from the Vim - General mailing list archive at Nabble.com.
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php