Is there a way to fix vim not-noticing python if statements that have comments?
Consider the following block of code-
if (1==1):#Go forever
print "Wooo."
Vim doesn't see the :, due to the comment, so it insists that the print should be at the same indent level as the "if"
using http://开发者_如何学JAVAwww.vim.org/scripts/script.php?script_id=974
Any thoughts would be appreciated.
Find this in the .vim file:
" If the previous line ended with a colon, indent relative to
" statement start.
if pline =~ ':\s*$'
change it to...
" If the previous line ended with a colon, indent relative to
" statement start.
if pline =~ ':\s*\(#.*\)\?$'
That will make it also match lines that end with a colon followed by a comment.
精彩评论