Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim jump to next match without affecting search pattern

Tags:

vim

Is there a way to jump to a fixed string in VIM without affecting the search history?

Say I want to use the key ;f to jump to the next function, and ;s to the next section.

I can do this:

nmap ;f /function<CR>
nmap ;s /section<CR> 

These work fine, but they overwrite the last search pattern. I want to jump nut keep the old search string.

like image 820
Ayman Avatar asked Feb 20 '23 19:02

Ayman


1 Answers

You can call vim function search()

nmap ;f :call search('function')<CR>
nmap ;s :call search('section')<CR> 
like image 124
kev Avatar answered Mar 04 '23 06:03

kev