If an operator is executed with a ":" command and the ":" command
doesn't invoke Visual mode via :normal, the whole operation can be
repeated correctly with the "." command. In this case, the ":" command
is stored into the redo buffer as is. For example:
------------------------------------------------------------------------
onoremap foo :<C-u>call Select()<CR>
function! Select()
" Select a region without ":normal v".
let p = getpos('.')
let p[2] += 3
call setpos('.', p)
endfunction
call setline('.', 'abc defg hijkl')
normal! 0
silent normal dfoo
echomsg string(getline('.'))
"==> ' defg hijkl'
delfunction Select
call setline('.', 'abc defg hijkl')
normal! 0w
let v:errmsg = ''
silent! normal! .
echomsg string(v:errmsg)
"==> 'E117: Unknown function: Select'
echomsg string(getline('.'))
"==> 'abc defg hijkl'
------------------------------------------------------------------------
But if an operator is executed with a ":" command and the ":" command
invokes Visual mode via :normal, the whole operation cannot be
repeated correctly with the "." command. In this case, the ":" command
is not stored into the redo buffer. For example:
------------------------------------------------------------------------
onoremap foo :<C-u>call Select()<CR>
function! Select()
" Select a region with ":normal v".
normal! viw
endfunction
call setline('.', 'abc defg hijkl')
normal! 0
silent normal dfoo
echomsg string(getline('.'))
"==> ' defg hijkl'
delfunction Select
call setline('.', 'abc defg hijkl')
normal! 0w
let v:errmsg = ''
silent! normal! .
echomsg string(v:errmsg)
"==> '', but it should be 'E117: Unknown function: Select'
echomsg string(getline('.'))
"==> 'abc g hijkl', but it should be 'abc defg hijkl'
------------------------------------------------------------------------
In the last example, the "." command repeats the last operation without
error, even if the Select function is no longer existing. So that the
redo buffer doesn't contains the last given ":" command as is.
The ":normal v" trick is necessary to define text objects like iw, ap
and others, because such text objects have to adjust the starting
position of a pending operator from Operator-pending mode.
But ":normal v" triggers the problem as described above.
Is this behavior intentional one, or unintended drawback?
Don't you have any idea about this problem?