python - vim新标签页缩进变化

标签 python vim

我使用的是 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/

相关文章:

python - OpenCV 读取视频文件在 Python 中非常慢

python - 从 Python 守护进程认真打印到标准输出

python - Aptana 配置 : The interpreter configured does not exist in the filesystem

vim - 为什么我的 MacVIM 和终端 vi 看起来不同?

python - 如何在列表理解期间检查列表的条件?

字符串选项的 Python 3 类型提示

vim - 如何在vim中直观地移动光标?(不是按行)

vim - 如何通过快捷方式使窗口水平或垂直相等?

python - 如何在 Vim 中通过 ALE 运行 isort?

vim - 当我的 .vimrc 被覆盖时我应该在哪里看