Auto Indent Doesn't Work When Using Vim Coding Python
I want to use vim to write python code but there is a problem on auto indention. First I downloaded the latest python.vim from http://www.vim.org/scripts/script.php?script_id=790 a
Solution 1:
I have this line in my vimrc for long time, don't know if there is better way nowadays. but you could at least give it a try.
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
and I have
filetype plugin indent on
too
Solution 2:
That vim script you linked to doesn't do any auto-indentation, only syntax highlighting.
The auto-indentation you are observing is the one that's built into vim, it is designed for coding C, and it only recognizes the keywords described here:
http://vimdoc.sourceforge.net/htmldoc/options.html#%27cinwords%27
That's why it works for if
and while
but not def
(there's no def
in C).
You turned it on with set cindent
.
You may want to try another script like this one:
Post a Comment for "Auto Indent Doesn't Work When Using Vim Coding Python"