I'm trying to make it easier to refactor stuff by running a single command that "performs the last rename interactively".
I have a binding for doing this that sort of works, but I'm curious whether there's a way to prevent it from ever getting "out of sync" by replacing an old substitution with a recent edit.
so far the best I've been able to find is this, which clobbers a register and a marker and the user to manually "wrap" commands so that they populate the contents of the
p register. It's also very easy for
<leader>, to pick up a new edit and there's absolutely no indication that this has happened.
nnoremap ciw mP"pyiw`Pciw nnoremap <silent> <leader>, :%s/<c-r>p/<c-r>./gc<cr>
I'd like to be able to start with a file that looks like this:
AAAA (instant 1) AAAA AAAA AAAA
run the following commands
gg0ciwBBBBBBB<esc>, get the following buffer
BBBBBBB (instant 2) AAAA AAAA AAAA
ciw has been remapped, running
<leader>, causes the buffer to look like this
BBBBBBB (instant 3) BBBBBBB BBBBBBB BBBBBBB
This is correct behavior. If, however, I performed I inserted and then deleted some text after
(instant 2). By performing
0ia<esc> and then
aBBBBBBB (instant 2.1 -- alternate) AAAA AAAA AAAA BBBBBBB (instant 2.2 -- alternate) AAAA AAAA AAAA
<leader>, will result in the following buffer
BBBBBBB (instant 3 -- alternate) a a a
the correct identifier
AAAA was targeted, but the contents of the
. register has changed. I'd like a solution where performing a mismatched substitution is simply impossible.