2015-02-09 85 views
1

當我使用等號在vim中縮進文本時,它用3個空格縮進它。我需要4. 我試圖在.vimrc文件中更改它的代碼(受我發現的一些示例的啓發,但它不起作用):Vim:如何將自動縮進(使用等號)設置爲4個空格?

autocmd BufWinLeave *.* mkview 
autocmd BufWinEnter *.* silent loadview 
set smartindent 
set tabstop=4  " The width of a TAB is set to 4. 
        " Still it is a \t. It is just that 
        " Vim will interpret it to be having 
        " a width of 4. 

set shiftwidth=4 " Indents will have a width of 4 

set softtabstop=4 " Sets the number of columns for a TAB 

set expandtab  " Expand TABs to spaces 

您知道如何將自動縮進(通過使用等號)更改爲4個空格嗎?非常感謝所有幫助

+0

在許多文件中,一行的縮進取決於上面的行。你能舉一些例子文本和文件類型嗎? – Ben 2015-02-09 17:30:24

+0

不要將縮進設置放在'〜/ .vimrc'文件中。它們是緩衝區本地設置,通常應通過filetype應用於每個緩衝區。而是在'〜/ .vim/after/ftplugin/python.vim'中把你的縮進設置放在'setlocal tabstop = 4'中。 – 2015-02-10 15:46:56

回答

0

=不會觸發智能縮進時,會觸發equalprg或者,如果沒有設置lispcindent,或indentexpr。要使用智能縮進,請使用><(如:>>縮進當前行,<<移出當前行,>2j縮進當前行和縮進當前行,等等)。當然,你可以重新映射它,如果你喜歡...

你smartindent的主要選項是正確的(shiftwidth,tabstop)。您對tabstop的評論說保留了選項卡,但您稍後通過設置expandtab更改了該選項卡。

相關問題