2016-12-25 58 views
0

我想以某種方式縮進括號內的我的java代碼。這裏怎麼會看起來像一個虛擬的例子:Vim:括號的縮進代碼,就像它對花括號一樣

public String hello(
    String really, 
    String looong, 
    String listOf, 
    Optional<String> params 
) { 
    return params.map((p) -> "Do something with the value " + p).orElse("world"); 
} 

我試圖用cinoptions解決這個問題,但好像沒有這樣的選擇。我不想最終爲java編寫定製的identexpr

回答

0

好,因爲我無法找到一個簡單的解決方案,我已經通過將下面的代碼重寫了Java中indentexpr到~/.vim/after/indent/java.vim

setlocal indentexpr=GetMyJavaIndent() 
function GetMyJavaIndent() 
    " When the line starts with a), try aligning it with the matching (
    if getline(v:lnum) =~ '^\s*)' 
     call cursor(v:lnum, 1) 
     silent normal! % 
     let lnum = line('.') 
     if lnum < v:lnum 
      return indent(lnum) 
     endif 
    endif 
    return GetJavaIndent() 
endfunction