在vimrc中将tab设置为2个空格,但是在编辑python文件时仍设置为4个空格 [英] Set tab as 2 spaces in vimrc, but still set to 4 spaces when editing python files
本文介绍了在vimrc中将tab设置为2个空格,但是在编辑python文件时仍设置为4个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在vimrc中将制表符设置为等于2个空格.当我编辑java文件时,此方法有效,但由于某些原因,当我编辑python文件时,tab改为设置为4个空格.
I've set tab to equal 2 spaces in my vimrc. This works when I edit java files, but for some reason when I edit python files, tab is set to 4 spaces instead.
我的vimrc:
filetype plugin indent on
syntax on
set backspace=indent,eol,start
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set showtabline=2
set number
set showcmd
set cursorline
set wildmenu
set lazyredraw
set showmatch
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'NLKNguyen/papercolor-theme'
Plug 'rakr/vim-one'
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-commentary'
Plug 'ajh17/VimCompletesMe'
Plug 'sheerun/vim-polyglot'
call plug#end()
highlight ColorColumn ctermbg=gray
set colorcolumn=81
autocmd BufNewFile,BufRead * setlocal formatoptions=croqtn textwidth=80
set t_Co=256
set term=xterm-256color
let g:gruvbox_contrast_dark='dark'
colorscheme gruvbox
set background=dark
map <C-x> :NERDTreeToggle<CR>
noremap <TAB> <C-W>w
" autoclose matching quotes, braces and parentheses
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
inoremap jj <Esc>
inoremap <Esc> <Nop>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <C-y> <C-o>h
inoremap <C-u> <C-o>l
推荐答案
这是在文件类型的python插件中自动设置的.
This is set automatically in filetype's python plugin.
ftplugin/python.vim
ftplugin/python.vim
if !exists("g:python_recommended_style") || g:python_recommended_style != 0
" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
endif
因此您可以通过以下方式禁用它:
So you can disable it with:
let g:python_recommended_style = 0
filetype plugin indent on
syntax on
...
这篇关于在vimrc中将tab设置为2个空格,但是在编辑python文件时仍设置为4个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文