Friday, February 6, 2015

Re: Regex to find case differences

...
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! >


 
Thanks Tim, I didn't release we could use the \1 that way.  Once again I just assumed it could only be used in the replacement part.

To force the case sensitivity (regardless of the ignorecase setting) we can just add:
  :g/\C^\(\S*\)\s\+\<\1\>/sil! >

And to remove the ones that are identical (instead of indenting):
  :g/\C^\(\S*\)\s\+\<\1\>/d

And to reverse that (i.e. keep only the ones that do match):
  :v/\C^\(\S*\)\s\+\<\1\>/d

Hope this might help others.
David
 

--
--
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.

No comments: