Describe lastpattern " :h last-pattern let s:lines = ['1pattern_a', '2pattern_b', '3pattern_c', '4pattern_d', '5pattern_e'] function! s:reset_buffer() :1,$ delete call AddLines(s:lines) normal! Gddgg0zt endfunction Before all map / (incsearch-forward) map ? (incsearch-backward) map g/ (incsearch-stay) call s:reset_buffer() End Before each :1 normal! zt End After all :1,$ delete unmap / unmap ? unmap g/ let @/ = '' let g:incsearch#magic = '' End Context handle last-pattern It should handle empty pattern as last-pattern let @/ = s:lines[1] exec "normal" "/\" Assert Equals(line('.'), 2) Assert Equals(GetPosChar(), '2') End It should handle empty pattern with {offset} as last-pattern let @/ = s:lines[1] exec "normal" "//e\" Assert Equals(line('.'), '2') Assert Equals(GetPosChar(), 'b') End End Context handle last-pattern with improved magic option It should handle empty pattern as last-pattern let g:incsearch#magic = '\v' let @/ = s:lines[1] exec "normal" "/\" Assert Equals(line('.'), 2) Assert Equals(GetPosChar(), '2') End It should handle empty pattern with {offset} as last-pattern let g:incsearch#magic = '\v' let @/ = s:lines[1] exec "normal" "//e\" Assert Equals(line('.'), '2') Assert Equals(GetPosChar(), 'b') End End End