.vimrc configuration for Python

前端 未结 6 497
小鲜肉
小鲜肉 2020-12-23 14:53

My current .vimrc configuration is below:

set nohlsearch
set ai
set bg=dark
set showmatch
highlight SpecialKey ctermfg=DarkGray
set listchars=tab:>-,trail         


        
6条回答
  •  甜味超标
    2020-12-23 15:51

    The short answer is that your autocmd is missing the BufEnter trigger, so it isn't being fired when you create a new file. Try this instead:

     au BufEnter,BufRead *.py setlocal smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
    

    Note that I also changed the set to setlocal. This'll prevent these options from stomping on your other buffers' options.

    The "right" way to do what you're trying to do is to add filetype indent on to your .vimrc. This'll turn on the built-in filetype based indentation. Vim comes with Python indentation support. See :help filetype-indent-on for more info.

提交回复
热议问题