Vim line operations (e.g. dd) on wrapped text

I use wrap in vim, but I want vim to behave as if the lines have actual breaks in them (rather than “soft breaks” for rendering the screen).

I matched j with gj and k with gk for navigation. However, linear operations (such as dd) still affect the entire line, not the “screen line”. Is there a way to change this behavior so that 'dd' is limited by the screen line?

+4
source share
2 answers

You can create a key mapping:

:nnoremap dd g0dg$ 
+4
source

I would prefer to create a new statement, for example x in standby mode:

 onoremap x :norm! g0vg$<cr> xnoremap xg$og0o 

On the first display, dx will delete the line of the screen, yx will stretch the line of the screen (be careful, it will not be inserted into the line, but it will be symbolic), cx will delete the line of the screen and begin to insert the mode, etc.

On the second display, x in visual mode will expand the screen lines with visual selection.

I would not advise reassigning dd, because it can break plugins (if they use :normal instead of :normal! Or if they use :×××noremap :×××map instead :×××noremap .

+4
source

Source: https://habr.com/ru/post/1403033/


All Articles