Non*_*ker 8 python vim indentation
我想用vim编写python代码但是自动缩进有问题.首先,我从http://www.vim.org/scripts/script.php?script_id=790下载了最新的python.vim 并将其推入正确的目录.然后我编辑了我的vimrc.
syntax on
set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
"set cindent
set autoindent
set smartindent
set expandtab
set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf python
Run Code Online (Sandbox Code Playgroud)
现在我发现像'for','if','while'这样的关键字可以完美自动化.但它不适用于'def','try','除'.我该怎么办?非常感谢你.
我在vimrc中有这条线很长一段时间,不知道现在有没有更好的方法.但你至少可以尝试一下.
set cindent
autocmd FileType python setlocal foldmethod=indent smartindent shiftwidth=4 ts=4 et cinwords=if,elif,else,for,while,try,except,finally,def,class
Run Code Online (Sandbox Code Playgroud)
我有
filetype plugin indent on
Run Code Online (Sandbox Code Playgroud)
太