On Tue, Apr 25, 2006 at 10:38:08PM -0700, Gerald Lai wrote: > On Tue, 25 Apr 2006, Salman Khilji wrote: > > [snip] > >What I am looking for is that when I hit the 'n' key, > >VIM should move the cursor to the next match AND > >highlight it as well using, for example, the 'Search', > >or 'IncSearch', or the 'Todo' highlight group. As > >soon as I hit the 'n' key again, the previous > >highlight should disappear and the next one should get > >highlighted. > [snip] > > > With these assumptions > > set nohlsearch nocompatible > > you can try these mappings: > > cmap <C-n> <CR>/<Up> > cmap <C-p> <CR>?<Up> > > Hit Ctrl-n/p to move on to the next/previous search, while you have > incsearch highlight on.
Either I am confused or you are. Why use :cmap for this? I would suggest :nmap n n:match Search /\%#<C-R>//<CR> :nmap N N:match Search /\%#<C-R>//<CR> Note that vim is smart enough to avoid recursion here: you can use :nnoremap if you want, but :nmap is good enough. If this solution works well for you, please consider posting it as a vim tip: http://www.vim.org/tips/add_tip.php HTH --Benji Fisher