Ansgar's answer is plain right.
I'll explain it's parts to make it a methodology more than a recipe because I think that regular expressions are somehow cryptic.
:s/\<\S*abc\>//g
is a vim substitution command.
It means "in the current line (use %s for all lines) substitute the matches of the regular expression \<\S*abc\>
(delimited by the first two "/"s by the text contained between the last two "/"s, i.e., nothing. The ending "g" is for global and means to replace all the matches instead of only the first one.
The regexp is enclosed in escaped angle brackets \<
and \>
. These are word boundaries, meaning that the regexp will match text only within single words. Think that vim will split the text in words before attempting to match each one.
The escaped uppercase S is for non-witespace. \s
(lowercase) matches whitespace (spaces and tabs) while \S
(uppercase) matches all other.
Hence, \S*
means "non-whitespace characters zero or more times".
The abc
part simply matches that exact characters sequence.
Putting it all together, the regexp matches whole words made up of any sequence of characters followed by abc
, as max wanted.
Because of the way vim thinks of words, the any sequence of characters will not contain spaces and other characters that are word boundaries. The other characters list depends on the file type being edited and can be seen typing :set iskeyword
enter. This is the information used to split the text in words.