"Google" python style script not working
I'm trying to use the Google python indentation script, but it's not working for me. I want it to indent as follows:
very_long_function_name(
first_param,
I pasted its text onto the end of this vim script: and put it into ~/.vim/indent/python.vim
. Not sure why it's not working.
Edit: FIXED.
I modified the indent file as follows:
function GetGooglePythonIndent(lnum)
" Indent inside parens.
" Align with the open paren unless it is at the end of the line.
" E.g.
" open_paren_not_at_EOL(100,
" (200,
" 300),
" 400)
" open_paren_at_EOL(
" 100, 200, 300, 400)
call cursor(a:lnum, 1)
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
echo par_line par_col
if par_line > 0
call cursor(par_line, 1)
if par_col != col("$") - 1
return par_col
else
return indent(par_line) + &s开发者_如何转开发w " FIXED HERE. FIXED BY ADDING THIS LINE
endif
endif
" Delegate the rest to the original function.
return GetPythonIndent(a:lnum)
endfunction
You are probably missing filetype indent on
from your .vimrc.
Fixed by modifying the script and adding a missing line.
In my case, I had to copy the script to ~/.vim/after/indent/python.vim
as the built-in python indent script overridden the one I added to ~/.vim/indent/python.vim
.
I was able to see the loaded order by :scriptnames
command.
精彩评论