1

When searching for something in vim or gvim, I use the /. If I make a type and press enter, I need to type the string in again, hopefully a second time without a typo.

Is it possible to configure vim to have a recently searched list so I can <leader>-key something? If not, how do you handle typos when searching?

5

Use q/ to open the command-line window with the previous search history. As a bonus you can use your standard vim editing maps. For more help see :h q/.

Related Vimcasts episode: Refining search patterns with the command-line window

You can also use / then use the up arrow (similar to bash) to bring up the previous search.

To help with typo's consider turning on 'incsearch' to show the current match. You can add the following to your vimrc file:

set incsearch

See :h 'incsearch' for more information.

You may also be interested in traces.vim if you want highlighting for :substitute and ranges.

  • Nice, the up arrow also works with :%s/. I didn't know that either. Thanks for the post. – Registered User Jan 11 '18 at 16:41
1

Vim already has a recently searched list. You can use the up and down arrows to cycle through your search (or command) history.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.