diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index 18d4e96a..8bcc987a 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -18,16 +18,15 @@ hook global WinSetOption filetype=cpp %~ addhl -group cpp-highlight regex "^\h*?#.*?(?s\h+$d } catch %{} } + hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks^\h+yjP } catch %{} ] # preserve previous line indent + hook window InsertKey \n -id cpp-hooks %[ try %[ exec -draft k[{(]\h*$j ] catch %{} ] # indent after lines ending with { or ( + hook window InsertKey \} -id cpp-hooks %[ try %[ exec -draft ^\h+\}$< ] catch %{} ] # deindent on insert } alone on a line + hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks\h+$d } catch %{} ] # cleanup trailing white space son previous line ~ hook global WinSetOption filetype=(?!cpp).* %{ rmhl cpp-highlight - rmfilter cpp-filters rmhooks window cpp-hooks }