X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/fa0f4802afec544c313f4590825dd48400539440..b343736b69ae21d90d92a1c4e8e8c7e16035ae58:/indent/python.vim diff --git a/indent/python.vim b/indent/python.vim index d86eabb..0f58516 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -16,6 +16,9 @@ setlocal nolisp setlocal autoindent setlocal indentexpr=GetPythonPEPIndent(v:lnum) setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 let s:maxoff = 50 let s:block_rules = { @@ -179,6 +182,7 @@ function! s:indent_like_previous_line(lnum) let text = getline(lnum) let start = s:find_start_of_multiline_statement(lnum) let base = indent(start) + let current = indent(a:lnum) " Jump to last character in previous line. call cursor(lnum, len(text)) @@ -215,6 +219,13 @@ function! s:indent_like_previous_line(lnum) return -1 endif + " If this line is dedented and the number of indent spaces is valid + " (multiple of the indentation size), trust the user + let dedent_size = current - base + if dedent_size < 0 && current % s:sw() == 0 + return -1 + endif + " In all other cases, line up with the start of the previous statement. return base endfunction