Skip to main content
deleted 50 characters in body
Source Link

How do I get my cursor to not move to the last thing it replaced after a search and replace. No <C-o> or extra key presses. Is there some autocmd magic I can setup to listen on any substitute execution and perform a <C-o> automatically after it completes?

If you're curious about further details, it's really for this bread-and-butter mapping, search and replace word under cursor for the whole file, honoring case (I have set gdefault, that's why there's no g flag). I type the binding then start typing the replacement:

nnoremap <leader>sr :%s/<c-r><c-w>//I<left><left> gI<left><left><left>

and the neovim feature to animate the search and replace:

if has("nvim")
    set inccommand=nosplit " No preview window
endif

How do I get my cursor to not move to the last thing it replaced after a search and replace. No <C-o> or extra key presses. Is there some autocmd magic I can setup to listen on any substitute execution and perform a <C-o> automatically after it completes?

If you're curious about further details, it's really for this bread-and-butter mapping, search and replace word under cursor for the whole file, honoring case (I have set gdefault, that's why there's no g flag). I type the binding then start typing the replacement:

nnoremap <leader>sr :%s/<c-r><c-w>//I<left><left> 

and the neovim feature to animate the search and replace:

if has("nvim")
    set inccommand=nosplit " No preview window
endif

How do I get my cursor to not move to the last thing it replaced after a search and replace. No <C-o> or extra key presses. Is there some autocmd magic I can setup to listen on any substitute execution and perform a <C-o> automatically after it completes?

If you're curious about further details, it's really for this bread-and-butter mapping, search and replace word under cursor for the whole file, honoring case. I type the binding then start typing the replacement:

nnoremap <leader>sr :%s/<c-r><c-w>//gI<left><left><left>

and the neovim feature to animate the search and replace:

if has("nvim")
    set inccommand=nosplit " No preview window
endif
Source Link

Don't jump on search and replace

How do I get my cursor to not move to the last thing it replaced after a search and replace. No <C-o> or extra key presses. Is there some autocmd magic I can setup to listen on any substitute execution and perform a <C-o> automatically after it completes?

If you're curious about further details, it's really for this bread-and-butter mapping, search and replace word under cursor for the whole file, honoring case (I have set gdefault, that's why there's no g flag). I type the binding then start typing the replacement:

nnoremap <leader>sr :%s/<c-r><c-w>//I<left><left> 

and the neovim feature to animate the search and replace:

if has("nvim")
    set inccommand=nosplit " No preview window
endif