Let\'s say this is my text:
this is my text this
is my text this is my text
my text is this
I would like to highlight all text ex
I've implemented Benoit's clever regular expression as a custom :DeleteExcept
command in my PatternsOnText plugin. It offers other related commands like :SubstituteExcept
or :SubstituteInSearch
, too.
OP's example would be
:%DeleteExcept /text/
Comparing that with @Benoit's explicit command (:%s/\(^\|\(text\)\@<=\).\{-}\($\|text\)\@=//g
), it's a lot simpler.