简体   繁体   中英

Gvim does not write tabs

In C++ files that I edit with Gvim I have noticed that code lines which are in inside blocks
(curly braces {})
although are being shown on the screen with the correct amount of tabs in Gvim
(ie plus one tab from the code which is outside of this code block)
when I open the same files with an another editor like sublime text
that extra tab that must exist in every line inside the code block does not exist.
So after opening these files with a hex editor I noticed that Gvim does not write those extra tabs in the code blocks?

Why does this happen? Is it because of cindent? Also how can I fix this rather than auto-reformat every time?

I am pretty sure that vim will faithfully save all the characters that are in the buffer. Various options affect how tabs are displayed, and whether actual tab characters or spaces are used for indenting. You can check their values, and see where they were set (default, in your vimrc file, or by some plugin) with

:verbose set ts? sts? et? sw? sta? ci? pi?

(These and more related options are grouped together if you open an options window with :options and look at Section 15.) If you want to visually check where you have tab characters rather than spaces, you can :set hls and then search for tab characters (or :match Search '\\t' ) or you can :set list .

If you try all that and you still think that vim is not saving what is in the buffer, then there are odd things to check, like whether you have any BufWrite or related autocommands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM