Vim: how to remove spaces between cursor and code?

I have these lines

aaaaa bbbbbb cccccc dddddd 

If I have a cursor in a row with a in the first column, how can I move the group a in the same position as the rest of the rows?

0
source share
2 answers

There are three (generalized) ways to achieve your goal:

  • To manually adjust the indent on the left, you can use << to shift to the left once (repeat s . To get the desired level of indentation).

  • If you are already in insert mode, Ctrl + d will shift the current line to the left.

  • Indent automatically using = =

However, given your initial description of being in column 1 and wanting a match with the others, I probably would just use d t a to delete to the first a.

edit: as Tim Pot notes, d w is a more efficient way to remove a space in the first character. I'm not sure what exactly you are trying to execute from your description (i.e. just trying to remove the empty space or all characters before the start of a ?)

+4
source

If you are already in the first column, I would use d w to delete the word. This will remove all spaces between the current column and the word.

All other alternatives depend on the indent offset, which may or may not remove all spaces at a time, depending on your settings. Or you should use the literal d t a , which is also more keystrokes.

+2
source

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


All Articles