vim的新选项卡页缩进改变



我使用的是vim 7.4。

我的python缩进设置是默认的:setlocal expandtab shiftwth =4 softtabstop=4 tabstop=8

这一行取自/usr/share/vim/vim74/ftplugin/python

当我用命令"vim file1.py"打开vim时,tab键按预期产生4个空格。但是当我用cmd: ": table 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+>)', 'u1', '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库的作者来修复该行为。

set tabstop=4放到你的.vimrc里试试

最新更新