Indentation changes in new tab
I'm using vim 7.4.
My python indent settings are the default: setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
This line was taken from /usr/share/vim/vim74/ftplugin/python.vim which I didn't edit.
When I open vim with the command "vim file1.py" then the tab key produces 4 spaces as expected. But when I open a second file in another tab-page with the cmd: ":tabe file2.py", then the tab key produces 8 spaces.
How do I fix that?
My .vimrc is shown below:
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
only effects in the current buffer or window. Each vim tab has its own windows so they have their own local settings. You can make the tab settings global (by using set
instead of setlocal
in your vimrc), or pester the writers of the python lib to fix the behavior.
把set tabstop=4
放到你的.vimrc文件中,然后试一下。
上一篇: Vim自动删除Python注释中的缩进
下一篇: 新标签中的缩进更改