New answers tagged


I have not found a way to detect search highlighting. A character's search highlight seems to be invisible to vimscript. Having said that, you can detect when the cursor is in a search match by other means. searchcount().exact_match returns 1 if the cursor is in a search match. Thanks @D.BenKnoble. /\%#@/ can be used to determine whether the cursor is at ...


:help / should get you to :help pattern, from which you can learn all about vim’s syntax for patterns. Since they can used in more places than just /, it’s worth an initial read. In your case, one option is /\vaa ?bb ?cc


EDITED: You can use this: :g/Engine1/.,.+2w! >> Newfile.txt It will find all the occurence of Engine1 and copy his line with the two line below to the file Newfile.txt You can also create a personnal command: :command -nargs=1 MySearch :g/<args>/.,.+2w! >> file.txt After entering this command, if you try writting :MySearch Engine1 It will ...


I was trying to come up with something fairly short and found this novel approach (novel to me anyways...I'd never tried it before). There is an inverse counterpart to :g (global command): :v. This will run specified commands on all lines that don't match the given pattern. Because it's really easy to invoke when a pattern is already in use (i.e. :v// {cmds}...

Top 50 recent answers are included