Tip 528 Printable Monobook Previous Next
created August 10, 2003 · complexity intermediate · author Yada · version 5.7
Some useful mappings to make search results appear in the middle of the screen.
nmap n nmzz.`z nmap N Nmzz.`z nmap * *mzz.`z nmap # #mzz.`z nmap g* g*mzz.`z nmap g# g#mzz.`z
Comments
You can always make the cursor stay at the center of the screen. See :help 'scrolloff'.
Why set the marks? The following works without messing up existing marks:
nmap n nzz nmap N Nzz nmap * *zz nmap # #zz nmap g* g*zz nmap g# g#zz
Yes, you are right. The mark is not needed. I reserved my z mark for last search result.
Problem: If you use 'nmap n nzz' then the message "search hit BOTTOM, continuing at TOP" does not appear.
I don't have that problem.
I'm using
nmap n nzzzv nmap N Nzzzv nmap * *zzzv nmap # #zzzv nmap g* g*zzzv nmap g# g#zzzv
so that jumping to the next/previous search result opens the associated fold.
The above mappings preserve the "search hit BOTTOM, continuing at TOP" message under Vim 6.3.