“ Google” python样式脚本不起作用

| 我正在尝试使用Google python缩进脚本,但不适用于我。我希望它缩进如下:
very_long_function_name(
    first_param,
我将其文本粘贴到此vim脚本的末尾:并将其放入
~/.vim/indent/python.vim
中。不知道为什么它不起作用。 编辑:固定。 我修改了缩进文件,如下所示:
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
    
已邀请:
您的.vimrc文件中可能缺少
filetype indent on
。     
通过修改脚本并添加缺少的行来修复。     
就我而言,我必须将脚本复制到
~/.vim/after/indent/python.vim
,因为内置的python缩进脚本会覆盖我添加到
~/.vim/indent/python.vim
的脚本。 我可以通过
:scriptnames
命令查看加载的订单。     

要回复问题请先登录注册