Stay in Search Mode
You are probably already aware that you can search in Vim by typing /
and entering a pattern. Typically you might search like so:
/some_pattern<CR>
Hitting <CR>
, aka carriage return or “Enter”, immediately exits search mode. That means that refining the search patterns and running it again requires that you return to search mode using /
followed by the up arrow to reenter the previous pattern. Then you can modify the pattern and try again. But there is a better way!
ctrl-g
– Jumps to the next occurrence of the pattern, but keeps focus in the command linectrl-t
– Jumps to the previous occurrence, but again keeps focus in your search
This allows for a search workflow that where you can see and page through the matches while modifying and refining your search pattern. Here’s a short screencast of these in action:

This doesn’t work in iterm on mac. Whe pressing ctrl + g i get ^G right after my pattern
Maybe I have found the answer: https://stackoverflow.com/questions/40192919/how-to-do-incremenatal-search-in-vim-like-it-is-done-in-emacs
It seems that vim support the feature after Patch 7.4.2268.
You can check your vim version. : )
To use this trick in #vim one must first execute the command :set incsearch
This doesn’t work in WindowsTerminal on WSL2 too. Whe pressing ctrl + g /ctrl + t I get ^G/^T right after my pattern.
Maybe I have found the answer: https://stackoverflow.com/questions/40192919/how-to-do-incremenatal-search-in-vim-like-it-is-done-in-emacs
It seems that vim support the feature after Patch 7.4.2268.
This is nice – but it needs `incsearch` to be set.