"Google" python样式脚本不起作用 [英] "Google" python style script not working
本文介绍了"Google" python样式脚本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Google python缩进脚本,但这对我不起作用.我希望它缩进如下:
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,
我将其文本粘贴到此vim脚本的末尾:并将其放入~/.vim/indent/python.vim
.不知道为什么它不起作用.
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.
已修复.
我对缩进文件进行了如下修改:
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) + &sw " FIXED HERE. FIXED BY ADDING THIS LINE
endif
endif
" Delegate the rest to the original function.
return GetPythonIndent(a:lnum)
endfunction
推荐答案
已通过修改脚本并添加缺少的行来解决.
Fixed by modifying the script and adding a missing line.
这篇关于"Google" python样式脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文