Now mappings can be remapped in `.vimrc` by
`nnoremap <key> <Plug>(RepeatUndoLine)`
and disablabled in `.vimrc` by
`nnoremap <SID>(DisableRepeatUndoLine) <Plug>(RepeatUndoLine)`
* Fix adding trailing spaces when 've' is not empty.
* Don't increment b:changedtick, offer invalidate instead.
* Support repetition with original register.
* Don't clobber existing U map.
* Respect 'foldopen' on undo.
* Allow customizing all mappings.
f1d0fbbdf4 allowed customizing the .
mapping by making the implementation function publicly accessible. Let's
do the same to s:wrap(), so that the other mappings (u, U, <C-R>) can be
extended, too.
(Personally, I'd like to have undo / redo stop and beep at the last
saved position, to avoid that I accidentally undo beyond the saved state
even though I didn't intend to.)
Need to :execute the :silent! call to avoid that the remainder of the
command line is aborted together with the call when repeat.vim is not
installed. Otherwise, <SID>MyFunction() won't be invoked, and the
mapping does nothing.
Since there seems to be a bug with "norm" in Vim prior to 7.3.100,
better go back to using feedkeys.
The repeat call can still be remapped by using something like:
nnoremap . :call repeat#run(v:count)<bar>call feedkeys('`.', 'n')<cr>
For commands that take an optional register (like p/P), Vim uses the
same register on repetition. This enhancement allows the same for custom
mappings, which need to call repeat#setreg() before repeat#set(). (No
changes for the vast majority of mappings that don't use registers.) It
even supports repeat of the expression register, with the expression
being re-evaluated on repeat.
repeat#set() so far automatically incremented b:changedtick. Problems
with this:
1. The way that was done clobbered the expression register "=.
2. It causes the "readonly" warning and "Cannot make changes" error in
readonly/nomodifiable buffers, so mappings that don't modify anything
cannot be repeated there.
3. It's actually not needed most of the time, because many user mappings
and all repeatable Vim built-in normal mode commands I know (with the
exception of yank with cpo+=y) actually do modify the buffer
themselves.
For the exceptional case where the user has a set of related mappings,
one that repeats naturally (e.g. a custom operator, via g@), and one
that invokes repeat#set(), and both do not modify the buffer, a new
function repeat#invalidate() is offered. This should be called by the
former mapping, and all is well.
The problem appears when cursor is positioned after line end, thus
running p command (even with empty "-register) causes Vim to add spaces
from line end until cursor.