我使用的是 vim 7.4。
我的Python缩进设置是默认的:setlocal Expandtab shiftwidth=4 softtabstop=4 tabstop=8
此行取自/usr/share/vim/vim74/ftplugin/python.vim,我没有编辑。
当我使用命令“vim file1.py”打开 vim 时,tab 键会按预期产生 4 个空格。但是,当我使用 cmd: ":tabe file2.py"在另一个选项卡页中打开第二个文件时,Tab 键会产生 8 个空格。
我该如何解决这个问题?
我的.vimrc如下所示:
syntax on " Enable syntax highlighting
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
set showmatch " Show matching brackets
set nu " Show line numbers
set expandtab " use spaces instead of tab chars
" open replace dialog for replacing selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" With the following (for example, in vimrc), you can visually select text then press ~ to convert the text to UPPER CASE, then to lower case, then to Title Case. Keep pressing ~ until you get the case you want.
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")<CR>Pgv
:let mapleader = "-"
:let maplocalleader = "\\"
最佳答案
:setlocal
仅在当前缓冲区或窗口中有效。每个 vim 选项卡都有自己的窗口,因此它们有自己的本地设置。您可以将选项卡设置设为全局(通过在 vimrc 中使用 set
而不是 setlocal
),或者纠缠 python 库的编写者来修复该行为。
关于python - vim新标签页缩进变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30473103/