如果Vim在我键入空行时自动进行取消缩进,将会非常有用,但似乎这不是默认行为。这对Python特别有用,Vim能够配置吗?
我对自己的indent/python.vim
进行了一些修改,以在输入第三个空行时启用完全取消缩进。您可以根据自己的需求进行调整。
diff --git a/python.vim b/python.vim
index 0c04e81..c60c30e 100644
--- a/python.vim
+++ b/python.vim
@@ -142,8 +142,14 @@ function GetPythonIndent(lnum)
" If not, recommend one dedent
return indent(plnum) - &sw
endif
- " Otherwise, trust the user
- return -1
+
+ " Is user trying to break out of this function?
+ if plnum < a:lnum - 2
+ return 0
+ else
+ " Otherwise, trust the user
+ return -1
+ endif
endif
" If the current line begins with a keyword that lines up with "try"
@@ -186,6 +192,11 @@ function GetPythonIndent(lnum)
return plindent
endif
+ " Double linebreaks means we're starting a new function (probably)
+ if plnum < a:lnum - 2
+ return 0
+ endif
+
return -1
endfunction
vim -u NONE -N
),然后逐个加载插件,直到找出是哪个插件导致了这种情况。 - Michael Foukarakis<c-d>
可以减少缩进级别。 - Peter Rincker