diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 1ac3dddc..b9765d86 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -42,8 +42,13 @@ def -hidden _c-family-trim-autoindent %[ eval -draft -itersel %[ def -hidden _c-family-indent-on-newline %[ eval -draft -itersel %[ exec \; - ## indent new lines with the same level as the previous one - exec -draft K + try %[ + ## if previous line closed a paren, copy indent of the opening paren line + exec -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?$ mJ s\`|.\' 1 + ] catch %[ + ## else indent new lines with the same level as the previous one + exec -draft K + ] ## remove previous empty lines resulting from the automatic indent try %[ exec -draft k H ^\h+$ d ] ## indent after an opening brace