2011-04-17 79 views
1

我試圖使用Google python indentation script,但它不適用於我。我希望它縮進如下:「Google」python樣式腳本不工作

very_long_function_name(
    first_param, 

我粘貼它的文本上的this vim script:末,放入~/.vim/indent/python.vim。不知道爲什麼它不起作用。


編輯:FIXED。

我修改縮進文件如下:

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 

回答

0

通過修改腳本並添加缺少的行來修復。

2

你可能漏掉您的.vimrc filetype indent on

+0

謝謝,但鍵入':filetype'給出'filetype檢測:ON插件:ON indent:ON' – 2011-04-17 22:42:48

+0

你可以發佈你的.vimrc嗎? – 2011-04-17 22:45:28

+0

是的,非常感謝。現在就這樣做。 – 2011-04-17 22:47:17