summaryrefslogtreecommitdiff
path: root/src/rc/cpp.kak
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-11-05 23:50:44 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-11-05 23:50:44 +0000
commit7495d04a4714230d89b5d3fd6390dca36f50d85d (patch)
treebc8482d8512c2c5078013e3212c62d3992e058dc /src/rc/cpp.kak
parent088f670fe94cd234643d41bfe1be71e0bf55da14 (diff)
Add support for -itersel option in exec/eval
-itersel makes a -draft eval/exec run once for each selections separately rather than with all selections at a time.
Diffstat (limited to 'src/rc/cpp.kak')
-rw-r--r--src/rc/cpp.kak6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak
index d02da331..c5b0f422 100644
--- a/src/rc/cpp.kak
+++ b/src/rc/cpp.kak
@@ -19,13 +19,13 @@ hook global WinSetOption filetype=cpp %~
addhl -group cpp-highlight regex "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string
addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment
hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } } # cleanup trailing whitespaces when exiting insert mode
- hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s\h+$<ret>d } ] # cleanup trailing white space son previous line
- hook window InsertChar \n -id cpp-indent %@
+ hook window InsertChar \n -id cpp-indent %@ eval -draft -itersel %_
try %{ exec -draft k<a-x>s^\h+<ret>yj<a-h>P } # preserve previous line indent
try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] # indent after lines ending with { or (
+ try %{ exec -draft k<a-x>s\h+$<ret>d } # cleanup trailing white space son previous line
try %{ exec -draft [(<a-k>\`\([^\n]+\n[^\n]*\n?\'<ret>s\`..|.\'<ret>& } # align to opening paren of previous line
- @
+ _ @
hook window InsertChar \} -id cpp-indent %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] ] # deindent on insert } alone on a line
~