0

When I use sublime text I find that it starts searching every time I press a key in the search, i.e. every time I add another letter to the searchsublime performs the search and shows a match with all that I typed.

In vim once I type / and input a search I need to press Enter for the search to be performed.

Is there a way to have vim with a similar behavior to sublime?

  • You can press / in normal mode and then type the text/pattern to search. You want more simplified than this? – SibiCoder Jun 26 '16 at 14:14
  • 6
    You mean, autocompletion? Please describe the behavior, don't assume Vim users know about Sublime-anything :) – VanLaser Jun 26 '16 at 14:28
  • Yes, immediately when I pressed key on keyboard make search, but keep my cursor in command panel and when I push ENTER move cursor into text area – Georgy Grigoryev Jun 26 '16 at 14:29
8

If you want to highlight matches as you search, you need to set incsearch. Read :help 'incsearch' for full details.

incsearch will scroll to the first match. Pressing <esc> while searching will cancel and restore the scroll position. Pressing <enter> will move the cursor to the first match.

You can change the incremental search highlight using the IncSearch highlight group.

There is also a plugin called incsearch.vim that will highlight all matches as you type, in addition to other features.

  • 2
    Also, there is the incsearch plugin. One of my absolute favorites, absolutely recommend it! – DJMcMayhem Jun 27 '16 at 4:44
  • @DJMcMayhem Thanks, that does look like a great plugin! I updated the answer with a link. – Tommy A Jun 27 '16 at 16:06
  • Should you not also include this link? – Tumbler41 Jun 27 '16 at 16:14
  • 1
    @Tumbler41 Nah. vim.org's script listings tend to be less informative if the plugin is hosted on GitHub. Besides, the more informative GitHub page has a link to vim.org. With the inability to format text or add images, linking to vim.org/scripts is a good way to not impress someone relatively new to Vim, IMO. – Tommy A Jun 27 '16 at 18:28

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.