Is there a visual flash effect for editing?

What we are looking for is a visual short-term display of the affected vim editing areas in normal mode. For example, when editing

if (true) { //line to be deleted } 

if we do dd on //line to be deleted , this area should be minimized before deletion, the same can be done with Vd . What we are looking at is the same as Vd using dd . This should work for all editing operations like c , y , etc.

We tried to match it with nnoremap dd Vd to check one line, no luck. Not even sure if we should look like this.

Google search did not cause anything satisfactory. Is there any known plugin? Any code that can be connected to vim will also be great

+7
vim vi
source share
1 answer

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.

+5
source share

All Articles