Remove spaces on multiple lines in VIM

To cancel the HAML code, I usually add or remove 2 spaces. Addendum:

  • Enter visual mode (ctrl + v)
  • jj to select strings
  • shift + i to enter insert
  • type 2 spaces
  • Esc

This is added 2 spaces. However, to remove spaces, I am not working, for example:

  • Enter visual mode (ctrl + v)
  • jj to select strings
  • shift + i to enter insert
  • Delete 2 spaces (with inverse space or delete)
  • Esc

It just doesn't work; other spaces are not removed. How then can I do this?

Here is a sample code:


 .module_1
     .pricing_details
       %h2
         Save

The idea moves everything so that it matches 2 places in relation to .module_1 as:


 .module_1
   .pricing_details
     %h2
       Save

The proposed solution using <> only works for indentation now, I would like, for example:


 .module_1
   .pricing_details
     %h2
       Save

move up:


 .module_1
 .pricing_details
   %h2
     Save
+3
source share
3 answers

< >. :set shiftwidth=2, .


UPDATE

,

.module_1
  .pricing_details
    %h2
      Save

.module_1
.pricing_details
  %h2
    Save

.pricing_details Vjj<.

+6

:

<

:

.

. , , . 2, 2, :

:set sw=2

, " > ".

: http://vimdoc.sourceforge.net/htmldoc/usr_25.html#25.3

+3

vimrc:

" pressing F5 adds two spaces at beginning of line and goes to next line
inoremap <F5> <ESC>:s/\(.*\)/  \1/e<CR>:set nohlsearch<CR>ji
" also works when not in edit mode
map <F5> i<F5><ESC>

" F6 removes two spaces from the end of whitespace at the beginning of line
inoremap <F6> <ESC>:s/\(^\s*\)/\1/e<CR>:set nohlsearch<CR>ji
map <F6> i<F6><ESC>

2 , F5 .

C ( , )

- , .

-1

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


All Articles