Vim replaces reeds with double spaces

So, I wrote some assignment code, and I forgot the university policy indentation with 2 spaces.

I usually put: //vim: ts=2:tw=78: et:

at the top of my files, but this time I forgot.

How do I go to replace all tabs with 2 spaces? would with / [TAB] / [SPACE] [SPACE] Work? (replacing [TAB] and [SPACE] with the corresponding keystrokes for the characters)

+3
source share
3 answers

You have to look retab. Install first tabstop, shiftwidthand expandtabthen use the command retab: it will reformat your entire file in the desired format.

+9
source

How do I go to replace all tabs with 2 spaces?

You can do

:%s/\t/  /g
+8

:

:set expandtab tabstop=2 shiftwidth=2 softtabstop=2
:retab!

screencast : http://vimcasts.org/episodes/tidying-whitespace/.

+2

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


All Articles