On 2015-02-06 11:25, David Fishburn wrote:
> John.Smith John.Smith
> Joe.Blow Joe.blow
> Sarah.Smith sarah.smith
Just for completeness in your test-cases, I'd add
John.Smith John.Smithe
where the 2nd one matches the 1st one as a prefix but it's not a
complete match.
You've got a couple options depending on what you want to do with
them. You can use a decorate-those-that-match approach such as
:g/^\(\S*\)\s\+\<\1\>/sil! >
which will indent those that do match case so those that aren't
indented have mismatches.
Alternatively, if you just want to do a search for them, you could do
/^\(\S*\)\s\+\<\%(\1\>\)\@!
which breaks down as
^ " start of line
\( " capture the 1st name
\S* " any non-whitespace
\) " end of the capture group
" you could add an optional \ze here to only match the 1st word
\s\+ " some mandatory whitespace
\< " ensure that we're at the start of the next item
\%( " begin a non-capturing group
\1 " check if the first item matches here
\> " and also ends here
\) " end of the non-capturing group
\@! " assert that the 1st item + end-of-word doesn't happen here
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Friday, February 6, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment