Can i do vim multi-line editing?

I combined the python file with vimdiff, and the result is something like this:

def code(): line 1 line 2 line 3 line 4 ... line n 

In this state, indentation is incompatible. How could I remove all spaces before the lines? I tried in visual mode, but selected the entire line. Does vim have multi-line editing? Notepad ++ allows this with Alt-Shift.

+6
source share
4 answers

Ctrl-V to select blocks.

Or, to remove all spaces at the beginning of all lines in a file:

 :%s/^\s\+ 
+6
source

There are at least two solutions to your problem:

  • There is a block lock mode that you enter with Ctrl v . You can select spaces at the beginning of your lines and press d .

  • Alternatively, you can select the line of the line you want to change by entering visual mode with SHift v (then use the down arrow or j to select). And then use < to remove one level of indentation. Use . to repeat the last operation if you want to remove several indents.

+6
source

Shift V will take you to visual line mode, and then you can press : to enter a command to execute only for selected lines.

+3
source

In VISUAL mode, you need to select all the rows you want to drag and press = .

I have never used Notepad ++, but I think that what you call multi-line editing is possible with Vim calling VISUAL BLOCK: instead of V hit <Cv> . Then you can select the rectangular parts of the text. After you have a column, press I or A to enter EDIT mode, then <Esc> to apply your editing to all rows. Since you want to remove one space, you need to visually select the space column and press x or d .

You can also do this with a simple search / replace, I think. Or use :norm .

+3
source

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


All Articles