Hacker News new | ask | show | jobs
by thrownawayalre 1354 days ago
Same feeling here with easymotion, sneak and others.

The built-in / with hlsearch on enter and nohlsearch on leave, together with the built-in <C-G> [1] for next match and <C-T> for previous match **while still in /** provides a faster and more natural solution because no need to read labels. From :help incsearch,

  set incsearch
  augroup vimrc-incsearch-highlight
   autocmd!
   autocmd CmdlineEnter /,\? :set hlsearch 
   autocmd CmdlineLeave /,\? :set nohlsearch
  augroup END
From there, type / and search for 1,2,3... characters (however many you want) and see the matches on the screen thanks to hlsearch being turned on. Go to next/previous match with <C-G> or <C-T> as desired. To close the movement, hit enter as usual with /.

For instance to delete until the second match of fum, type

   d/fum<C-G><ENTER>
and it is very easy to follow the current match among all highlighted matches because the current match has a different color.

[1]: see :help /_CTRL-G

1 comments

Nice tips.

Personally I have hlsearch turned on and nohlsearch mapped to H because persistent highlighting is sometimes useful, sometimes a bit annoying.