There are many things in the examples that I give, but they can be a good start to solve your problem.
You can use :redraw and :sleep to draw a selection for an instant while the function is running.
Here is an example with dd :
nmap <silent> dd :call Com_dd()<cr> function! Com_dd() range " Enter visual mode: normal! V " Select multiple lines, when there a range: let morelines = a:lastline - a:firstline if morelines != 0 exe "normal! ".morelines."j" endif " Redraw the screen so we can see the selection: redraw " Sleeps 200ms: sleep 200 m " Delete the selected lines: normal! d endf
It can be called with a range, for example: 3dd .
For teams with movements, this is a little more complicated, but you can get closer to the desired behavior, here is an example of the c command:
nmap <silent> c :set opfunc=Com_c<cr> g@ function! Com_c(type) let curpos = getpos('.') if a:0 " Invoked from Visual mode, use gv command. silent exe "normal! gv" elseif a:type == 'line' silent exe "normal! '[V']" else silent exe "normal! `[v`]" endif redraw sleep 200 m normal! d startinsert call setpos('.', curpos) endf
This last example does not handle ranges, so 3cw will not work (but c3w will work).
See :h g@ for help displaying the operator.
But this leads to some new problems:. no longer works with these commands, for example. Another example: the standard cw command does not remove the space after the word, but my example does.
You can find some solutions to these new problems, but right now I donβt have them.
yolenoyer
source share