Using gg = G in Vim to automatically bookmark a document when changing tabstop

Usually gg = G is used in vim to automatically bookmark C / C ++ / Java or any other code.

However, I changed my tabstop to tabstop = 2 in my default settings for vim, so that whenever I insert, I get the equivalent of 2 spaces instead of 8 by default.

Now, when I use gg = G, I get 4 tabs instead of 1 for indentation, so the interval looks equivalent earlier when I had tabstop = 8. I just want 1 tab. Is there any way to do this?

(I use hard tabs only for indentation, no spaces).

+4
source share
2 answers

, , shiftwidth. set sw=2 . :help sw

tabstop=2 set softtabstop=2. :help ts.

tab, .

vimrc

set softtabstop=2
set shiftwidth=2
set expandtab

4. 2 :)

+3

. tabstop , TAB. gg=G , "shiftwidth". set shiftwidth=2 1 4.:)

+1
source

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


All Articles