How does one keep the cursor in its place after a file-replace using :%s/find/replace/g
? I looked at restoring cursor position, but not quite what I was looking for, and I could jump back to previous position using ''
.
The anwolib plugin has a :KeepView
command:
:KeepView %s/find/replace/g
-
Is there a way to "enable"
KeepView
for all find-replace operations? I'm trying to minimize typing (_: – KM. Mar 16 '15 at 17:57 -
1You can create a shorter
:KV
alias command, or even:kv
using cmdalias.vim. To be even more extreme::nnoremap : :KeepView<Space>
– Ingo Karkat Mar 16 '15 at 19:59 -
1
''
or<C-o>
is sort of the answer :-) Do you want it to happen automatically? – Martin Tournoij Mar 16 '15 at 14:53