so I tried to remove any word that has a letter "a" in it with vim
I want to change this string
hotel echo lima lima oscar whiskey oscar romeo lima delta
to
hotel echo whiskey romeo
I hope I can do this on the vim, but no problem if I have to do this on paste, sed, etc. As long as I can do this on linux.
Thanks
2 Answers
Use the following:
s/\<\w*a\w*\> *//g Explanation:
s/ # substitute, delimiter \< # word boundary \w* # 0 or more word character a # letter a \w* # 0 or more word character \> # word boundary * # 0 or more spaces / # delimiter /g # delimiter, global 2One way is to put the cursor at the start of the line, search for /a, then daw ('delete a word'). You can then jump to the next match with n and press the . to repeat the deletion (and just keep spamming n + .). If the line is very long, you can record a macro with (put the cursor at the start of the line) with qqndaw, and just repeat the macro 100 times (or some sufficiently large number) with 100@q.