diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 1e2ae07b..d81c5809 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -9,6 +9,9 @@ released versions. * `!` and `` commands now select the inserted text +* `x` now just extends the selection to contain full lines (as `` did) + `` trims partial lines from the selection (as `` did) + == Kakoune 2021.11.07 * Support for curly and separately colored underlines (undocumented in 2021.10.28) diff --git a/doc/pages/keys.asciidoc b/doc/pages/keys.asciidoc index 95de80c7..29ddb54b 100644 --- a/doc/pages/keys.asciidoc +++ b/doc/pages/keys.asciidoc @@ -162,13 +162,9 @@ the Shift modifier and moving will extend each selection instead. characters, see the `matching_pairs` option in <> *x*:: - select line on which the end of each selection lies (or next line when end lies - on an end-of-line) - -**:: expand selections to contain full lines (including end-of-lines) -**:: +**:: trim selections to only contain full lines (not including last end-of-line) diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index a35af3c7..7c0dcf44 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -117,7 +117,7 @@ define-command -hidden modeline-parse-impl %{ define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ try %{ evaluate-commands -draft %{ execute-keys "s(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z" \ - s^\S*?\s+?\w+:\s?[^\n]+ + s^\S*?\s+?\w+:\s?[^\n]+ x evaluate-commands -draft -itersel modeline-parse-impl } } } diff --git a/rc/filetype/awk.kak b/rc/filetype/awk.kak index 85ec591a..536e3528 100644 --- a/rc/filetype/awk.kak +++ b/rc/filetype/awk.kak @@ -73,16 +73,16 @@ define-command -hidden awk-indent-on-new-line %[ # preserve previous line indent try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line - try %[ execute-keys -draft k s \h+$ d ] + try %[ execute-keys -draft k x s \h+$ d ] # indent after line ending in opening curly brace - try %[ execute-keys -draft k \{\h*(#.*)?$ j ] + try %[ execute-keys -draft kx \{\h*(#.*)?$ j ] # deindent closing brace when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] define-command -hidden awk-trim-indent %{ - try %{ execute-keys -draft s ^\h+$ d } + try %{ execute-keys -draft x s ^\h+$ d } } @ diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index 00f1a3d9..f56d9db2 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -64,7 +64,7 @@ provide-module c-family %§ define-command -hidden c-family-trim-indent %{ # remove the line if it's empty when leaving the insert mode - try %{ execute-keys -draft 1s^(\h+)$ d } + try %{ execute-keys -draft x 1s^(\h+)$ d } } define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -itersel %< @@ -75,31 +75,31 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i > catch %< # else if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + execute-keys -draft kx 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # remove previous empty lines resulting from the automatic indent - try %< execute-keys -draft k ^\h+$ Hd > + try %< execute-keys -draft k x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line - try %< execute-keys -draft k [{(]\h*$ j > + try %< execute-keys -draft k x [{(]\h*$ j > # indent after a label - try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > + try %< execute-keys -draft k x s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace - try %< execute-keys -draft k s\)\h*(?://[^\n]+)?\n\z \ + try %< execute-keys -draft k x s\)\h*(?://[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > - try %< execute-keys -draft k s \belse\b\h*(?://[^\n]+)?\n\z \ + try %< execute-keys -draft k x s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end - try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ - K s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ + K x s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > - try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ - K s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ + K x s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # deindent closing brace(s) when after cursor - try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > + try %< execute-keys -draft x ^\h*[})] gh / [})] m 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %< @@ -118,7 +118,7 @@ define-command -hidden c-family-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z 1 ] # align indent with opening paren when { is entered on a new line after the else - try %[ execute-keys -draft -itersel hK s \belse\b\h*(?://[^\n]+)?\n\h*\{ 1 ] + try %[ execute-keys -draft -itersel hK x s \belse\b\h*(?://[^\n]+)?\n\h*\{ 1 ] ] define-command -hidden c-family-indent-on-closing-curly-brace %[ @@ -134,7 +134,7 @@ define-command -hidden c-family-indent-on-closing-curly-brace %[ define-command -hidden c-family-insert-on-closing-curly-brace %[ # add a semicolon after a closing brace if part of a class, union or struct definition - try %[ execute-keys -itersel -draft hmB \A[^\n]+\)\h*(\{|$) \A\h*(class|struct|union|enum) ';i;' ] + try %[ execute-keys -itersel -draft hmxBx \A[^\n]+\)\h*(\{|$) \A\h*(class|struct|union|enum) ';i;' ] ] define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[ @@ -142,10 +142,10 @@ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix - execute-keys -save-regs '' k 1s^\h*(//+\h*) y + execute-keys -save-regs '' k x1s^\h*(//+\h*) y try %[ # if the previous comment isn't empty, create a new one - execute-keys ^\h*//+\h*$ js^\h*P + execute-keys x^\h*//+\h*$ jxs^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d @@ -153,28 +153,28 @@ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel ] # trim trailing whitespace on the previous line - try %[ execute-keys -draft k s\h+$ d ] + try %[ execute-keys -draft k x s\h+$ d ] ] try %[ # if the previous line isn't within a comment scope, break - execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + execute-keys -draft kx ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space - execute-keys -draft k^\h*/\* + execute-keys -draft kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star - execute-keys -draft j^\h+\* + execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope - execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + execute-keys -draft kx^\h+\*\h+$ x1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* @@ -183,9 +183,9 @@ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel ] # trim trailing whitespace on the previous line - try %[ execute-keys -draft k s\h+$ d ] + try %[ execute-keys -draft k x s\h+$ d ] # align the new star with the previous one - execute-keys K1s^[^*]*(\*)& + execute-keys Kx1s^[^*]*(\*)& ] ] ] diff --git a/rc/filetype/cabal.kak b/rc/filetype/cabal.kak index 42e56888..684542e2 100644 --- a/rc/filetype/cabal.kak +++ b/rc/filetype/cabal.kak @@ -48,13 +48,13 @@ add-highlighter shared/cabal/code/ regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:vari define-command -hidden cabal-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden cabal-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '--' comment prefix and following white spaces - try %[ execute-keys -draft k s ^\h*\K--\h* y gh j P ] + try %[ execute-keys -draft k x s ^\h*\K--\h* y gh j P ] ] ] @@ -65,9 +65,9 @@ define-command -hidden cabal-indent-on-new-line %[ # filter previous line try %[ execute-keys -draft k : cabal-trim-indent ] # indent after lines ending with { or : - try %[ execute-keys -draft k [:{]$ j ] + try %[ execute-keys -draft k x [:{]$ j ] # deindent closing brace when after cursor - try %[ execute-keys -draft \h*\} gh / \} m 1 ] + try %[ execute-keys -draft x \h*\} gh / \} m 1 ] ] ] diff --git a/rc/filetype/coffee.kak b/rc/filetype/coffee.kak index 58811a05..c9ee330c 100644 --- a/rc/filetype/coffee.kak +++ b/rc/filetype/coffee.kak @@ -65,7 +65,7 @@ add-highlighter shared/coffee/code/ regex \b(break|case|catch|class|const|contin define-command -hidden coffee-trim-indent %{ evaluate-commands -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -74,7 +74,7 @@ define-command -hidden coffee-trim-indent %{ define-command -hidden coffee-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s '^\h*\K#\h*' y gh j P } + try %{ execute-keys -draft k x s '^\h*\K#\h*' y gh j P } } } @@ -85,7 +85,7 @@ define-command -hidden coffee-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : coffee-trim-indent } # indent after start structure - try %{ execute-keys -draft k ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } + try %{ execute-keys -draft k x ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } diff --git a/rc/filetype/coq.kak b/rc/filetype/coq.kak index 5ef43c86..cab1abf8 100644 --- a/rc/filetype/coq.kak +++ b/rc/filetype/coq.kak @@ -112,13 +112,13 @@ evaluate-commands %sh{ # Hence here only a simple mechanism of copying indent is done. define-command -hidden coq-copy-indent-on-newline %{ evaluate-commands -draft -itersel %{ - try %{ execute-keys -draft k s ^\h+ y gh j P } + try %{ execute-keys -draft k x s ^\h+ y gh j P } } } define-command -hidden coq-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } diff --git a/rc/filetype/crystal.kak b/rc/filetype/crystal.kak index 7752698a..5a62e7dc 100644 --- a/rc/filetype/crystal.kak +++ b/rc/filetype/crystal.kak @@ -181,7 +181,7 @@ evaluate-commands %sh[ define-command -hidden crystal-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h+$ d } } @@ -190,15 +190,15 @@ define-command -hidden crystal-trim-indent %{ define-command -hidden crystal-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align 'else' to 'if/case' - try %{ execute-keys -draft ^\h*else$ i ^\h*(?:if|case) 1 } + try %{ execute-keys -draft x ^\h*else$ i ^\h*(?:if|case) 1 } # align 'elsif' to 'if' - try %{ execute-keys -draft ^\h*elsif$ i ^\h*(?:if) 1 } + try %{ execute-keys -draft x ^\h*elsif$ i ^\h*(?:if) 1 } # align 'when' to 'case' - try %{ execute-keys -draft ^\h*when$ i ^\h*(?:case) 1 } + try %{ execute-keys -draft x ^\h*when$ i ^\h*(?:case) 1 } # align 'rescue' to 'begin/def' - try %{ execute-keys -draft ^\h*rescue$ i ^\h*(?:begin|def) 1 } + try %{ execute-keys -draft x ^\h*rescue$ i ^\h*(?:begin|def) 1 } # align 'end' to opening structure - try %{ execute-keys -draft ^\h*end$ i ^\h*(?:begin|case|class|def|for|if|module|unless|until|while) 1 } + try %{ execute-keys -draft x ^\h*end$ i ^\h*(?:begin|case|class|def|for|if|module|unless|until|while) 1 } } } @@ -209,23 +209,23 @@ define-command -hidden crystal-indent-on-new-line %{ # Remove previous line's trailing spaces try %{ execute-keys -draft k :crystal-trim-indent } # Indent after start structure/opening statement - try %{ execute-keys -draft k ^\h*(?:begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] j } + try %{ execute-keys -draft k x ^\h*(?:begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] j } } } define-command -hidden crystal-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces - try %{ execute-keys -draft k s '^\h*\K#\h*' y j P } + try %{ execute-keys -draft k x s '^\h*\K#\h*' y j x P } # wisely add end structure evaluate-commands -save-regs x %[ - try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } + try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block - execute-keys -draft k ^x(?:begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] + execute-keys -draft kx ^x(?:begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] # Check that we do not already have an end for this indent level which is first set via `crystal-indent-on-new-line` hook - execute-keys -draft }i J ^x(?:end|else|elsif|rescue|when)[^0-9A-Za-z_!?] + execute-keys -draft }i J x ^x(?:end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index d80949bb..b498a43f 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -112,7 +112,7 @@ add-highlighter shared/css/attr_selector/single_string region "'" (? s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden css-indent-on-new-line %[ @@ -124,17 +124,17 @@ define-command -hidden css-indent-on-new-line %[ > catch %< # else if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + execute-keys -draft kx 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # filter previous line - try %< execute-keys -draft k ^\h+$ Hd > + try %< execute-keys -draft k x ^\h+$ Hd > # indent after lines ending with with { - try %[ execute-keys -draft k \{$ j ] + try %[ execute-keys -draft k x \{$ j ] # deindent closing brace when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] @@ -143,24 +143,24 @@ define-command -hidden css-insert-on-new-line %[ execute-keys try %[ # if the previous line isn't within a comment scope, break - execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + execute-keys -draft kx ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space - execute-keys -draft k^\h*/\* + execute-keys -draft kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star - execute-keys -draft j^\h+\* + execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope - execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + execute-keys -draft kx^\h+\*\h+$ x1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* @@ -171,7 +171,7 @@ define-command -hidden css-insert-on-new-line %[ # trim trailing whitespace on the previous line try %[ execute-keys -draft s\h+$ d ] # align the new star with the previous one - execute-keys K1s^[^*]*(\*)& + execute-keys Kx1s^[^*]*(\*)& ] > ] diff --git a/rc/filetype/cucumber.kak b/rc/filetype/cucumber.kak index 335d4933..00c2a42f 100644 --- a/rc/filetype/cucumber.kak +++ b/rc/filetype/cucumber.kak @@ -78,13 +78,13 @@ add-highlighter shared/cucumber/code/ regex \b(Feature|Business\h+Need|Ability|B define-command -hidden cucumber-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden cucumber-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } diff --git a/rc/filetype/cue.kak b/rc/filetype/cue.kak index c89845e4..f4008377 100644 --- a/rc/filetype/cue.kak +++ b/rc/filetype/cue.kak @@ -122,13 +122,13 @@ evaluate-commands %sh{ define-command -hidden cue-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden cue-insert-on-new-line %~ evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K//[!/]?\h* yP } + try %{ execute-keys -draft kx s ^\h*\K//[!/]?\h* yP } > ~ @@ -138,13 +138,13 @@ define-command -hidden cue-indent-on-new-line %~ try %{ execute-keys -draft K } try %< # only if we didn't copy a comment - execute-keys -draft ^\h*// + execute-keys -draft x ^\h*// # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft k x [{(]\h*$ j ] # indent after lines ending with [{(].+ and move first parameter to own line try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > # deindent closing brace(s) when after cursor - try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > + try %< execute-keys -draft x ^\h*[})] gh / [})] m 1 > > # filter previous line try %{ execute-keys -draft k : cue-trim-indent } diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak index f2d8a2a1..7d2f307b 100644 --- a/rc/filetype/d.kak +++ b/rc/filetype/d.kak @@ -17,7 +17,7 @@ hook global WinSetOption filetype=d %{ set-option window static_words %opt{d_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group d-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group d-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group d-insert d-insert-on-new-line hook window InsertChar \n -group d-indent d-indent-on-new-line hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace @@ -109,7 +109,7 @@ add-highlighter shared/d/code/ regex "\bmodule\s+([\w_-]+)\b" 1:module define-command -hidden d-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } = ~ @@ -118,17 +118,17 @@ define-command -hidden d-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements - try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] + try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] = ~ diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak index 2a2150b1..7091f1c5 100644 --- a/rc/filetype/dart.kak +++ b/rc/filetype/dart.kak @@ -17,7 +17,7 @@ hook global WinSetOption filetype=dart %{ set-option window static_words %opt{dart_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group dart-insert dart-insert-on-new-line hook window InsertChar \n -group dart-indent dart-indent-on-new-line hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace @@ -90,7 +90,7 @@ evaluate-commands %sh{ define-command -hidden dart-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } = ~ @@ -99,17 +99,17 @@ define-command -hidden dart-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements - try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] + try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] = ~ diff --git a/rc/filetype/dhall.kak b/rc/filetype/dhall.kak index 75ebc30f..94b69d66 100644 --- a/rc/filetype/dhall.kak +++ b/rc/filetype/dhall.kak @@ -78,13 +78,13 @@ add-highlighter shared/dhall/union/end regex > 0:operator define-command -hidden dhall-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden dhall-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden dhall-indent-on-new-line %{ diff --git a/rc/filetype/diff.kak b/rc/filetype/diff.kak index 9391ae1e..2655b9b5 100644 --- a/rc/filetype/diff.kak +++ b/rc/filetype/diff.kak @@ -34,7 +34,7 @@ define-command diff-jump -params .. -docstring %{ set-register c %val{cursor_column} # If there is a "diff" line, we don't need to look further back. try %{ - execute-keys %{^(?:> )*diff\b} + execute-keys %{^(?:> )*diff\bx} } catch %{ # A single file diff won't have a diff line. Start parsing from # the buffer start, so we can tell if +++/--- lines are headers diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index 5e099df2..9c060525 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -89,22 +89,22 @@ add-highlighter shared/elixir/code/ regex '\b\d+[\d_]*\b' 0:value define-command -hidden elixir-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden elixir-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y jgi P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y jgi P } # wisely add end structure evaluate-commands -save-regs x %[ - try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } + try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block - execute-keys -draft k ^x(.+\bdo$) + execute-keys -draft kx ^x(.+\bdo$) # Check that we do not already have an end for this indent level which is first set via `elixir-indent-on-new-line` hook - execute-keys -draft }i J ^x(end|else)[^0-9A-Za-z_!?] + execute-keys -draft }i J x ^x(end|else)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index d5a76fcf..0bd51967 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -55,7 +55,7 @@ add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![- define-command -hidden elm-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden elm-indent-after " @@ -65,7 +65,7 @@ define-command -hidden elm-indent-after " define-command -hidden elm-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } diff --git a/rc/filetype/elvish.kak b/rc/filetype/elvish.kak index 1b3eec07..53778626 100644 --- a/rc/filetype/elvish.kak +++ b/rc/filetype/elvish.kak @@ -39,7 +39,7 @@ add-highlighter shared/elvish/code/metachar regex [*?|&\;<>()[\]{}] 0:operator define-command -hidden elvish-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -49,19 +49,19 @@ define-command -hidden elvish-indent %< evaluate-commands -draft -itersel %< execute-keys try %< # if the previous line is a comment, copy indent, # and whitespace - execute-keys -draft k s^\h*#\h* yjP + execute-keys -draft k x s^\h*#\h* yjP > catch %< # copy indent execute-keys -draft K # indent after { [ ( | - try %< execute-keys -draft k [[{(|]\h*$ j > + try %< execute-keys -draft k x [[{(|]\h*$ j > > >> define-command -hidden elvish-deindent %< evaluate-commands -draft -itersel %< try %< # Deindent only when there is a lone closing character - execute-keys -draft ^\h*[^\h]$ + execute-keys -draft x ^\h*[^\h]$ > >> § diff --git a/rc/filetype/fidl.kak b/rc/filetype/fidl.kak index 4164d838..351eeb41 100644 --- a/rc/filetype/fidl.kak +++ b/rc/filetype/fidl.kak @@ -45,14 +45,14 @@ add-highlighter shared/fidl/code/literals/binary regex \b(0b[01])\b 0:value define-command -hidden fidl-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden fidl-indent-on-new-line %~ evaluate-commands -draft -itersel %@ try %{ # line comment # copy the commenting prefix - execute-keys -draft k s ^\h*/{2,}\h* yjghP + execute-keys -draft k x s ^\h*/{2,}\h* yjghP } catch %` # preserve previous line indent try %{ execute-keys -draft K } @@ -61,7 +61,7 @@ define-command -hidden fidl-indent-on-new-line %~ execute-keys -draft [)}] m 1 + catch %+ # indent after lines ending with ( or { - try %! execute-keys -draft k [({]$ j ! + try %! execute-keys -draft k x [({]$ j ! + ` # remove trailing white spaces diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index f2ca922f..0bfcc4f0 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -53,23 +53,23 @@ add-highlighter shared/fish/code/ regex \b(? 1s^(\h+)$ d } + try %{ execute-keys -draft x 1s^(\h+)$ d } } } define-command -hidden fish-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start and indent when necessary - try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z1 } - try %{ execute-keys -draft ^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } - try %{ execute-keys -draft ^\h*(case)$^\h*(switch)s\A|.\z1 } + try %{ execute-keys -draft x^\h*(else)$^\h*(if)s\A|.\z1 } + try %{ execute-keys -draft x^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } + try %{ execute-keys -draft x^\h*(case)$^\h*(switch)s\A|.\z1 } } } define-command -hidden fish-insert-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } } } @@ -78,9 +78,9 @@ define-command -hidden fish-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after start structure - try %{ execute-keys -draft k^\h*(begin|case|else|for|function|if|while)\bj } + try %{ execute-keys -draft kx^\h*(begin|case|else|for|function|if|while)\bj } } } diff --git a/rc/filetype/fsharp.kak b/rc/filetype/fsharp.kak index 03aab385..f2909e0b 100644 --- a/rc/filetype/fsharp.kak +++ b/rc/filetype/fsharp.kak @@ -128,7 +128,7 @@ add-highlighter shared/fsharp/code/ regex "\B(\(\))\B" 0:value define-command -hidden fsharp-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -137,7 +137,7 @@ define-command -hidden fsharp-trim-indent %{ define-command -hidden fsharp-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*//\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } @@ -146,11 +146,11 @@ define-command -hidden fsharp-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft \; K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with = - try %{ execute-keys -draft k =$ j } + try %{ execute-keys -draft k x =$ j } # indent after line ending with "do" - try %{ execute-keys -draft k \bdo$ j } + try %{ execute-keys -draft k x \bdo$ j } } } diff --git a/rc/filetype/gas.kak b/rc/filetype/gas.kak index 5f753d54..eb8d4c25 100644 --- a/rc/filetype/gas.kak +++ b/rc/filetype/gas.kak @@ -79,7 +79,7 @@ add-highlighter shared/gas/code/ regex \ define-command -hidden gas-trim-indent %{ evaluate-commands -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h+$ d } } @@ -92,7 +92,7 @@ define-command -hidden gas-indent-on-new-line %~ # filter previous line try %{ execute-keys -draft k : gas-trim-indent } # indent after label - try %[ execute-keys -draft k :$ j ] + try %[ execute-keys -draft k x :$ j ] > ~ diff --git a/rc/filetype/gdscript.kak b/rc/filetype/gdscript.kak index 167fc68c..7f716554 100644 --- a/rc/filetype/gdscript.kak +++ b/rc/filetype/gdscript.kak @@ -19,7 +19,7 @@ hook global WinSetOption filetype=gdscript %{ hook window InsertChar \n -group gdscript-insert gdscript-insert-on-new-line hook window InsertChar \n -group gdscript-indent gdscript-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group gdscript-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group gdscript-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gdscript-.+ } } @@ -90,7 +90,7 @@ add-highlighter shared/gdscript/code/ regex '\$[\w/]*' 0: define-command -hidden gdscript-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } } } @@ -99,11 +99,11 @@ define-command -hidden gdscript-indent-on-new-line %< # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with : - try %{ execute-keys -draft k :$ ^\h*# j } + try %{ execute-keys -draft k x :$ ^\h*# j } # deindent closing brace/bracket when after cursor (for arrays and dictionaries) - try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > + try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > diff --git a/rc/filetype/gluon.kak b/rc/filetype/gluon.kak index 17080cb9..2c4b96b4 100644 --- a/rc/filetype/gluon.kak +++ b/rc/filetype/gluon.kak @@ -76,13 +76,13 @@ add-highlighter shared/gluon/code/ regex \B'([^\\]|[\\]['"\w\d\\])' 0:string define-command -hidden gluon-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden gluon-insert-on-new-line %~ evaluate-commands -draft -itersel %_ # copy // and /// comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K///?\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K///?\h* y gh j P } _ ~ @@ -96,7 +96,7 @@ define-command -hidden gluon-indent-on-new-line %~ # or in try %{ execute-keys -draft \; k x (\(|\{|\[|=|->|\b(?:then|else|rec|in))$ j } # deindent closing brace(s) when after cursor - try %< execute-keys -draft ^\h*[})\]] gh / \})\]] m 1 > + try %< execute-keys -draft x ^\h*[})\]] gh / \})\]] m 1 > _ ~ diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index 416e38ff..af5a7a86 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -17,7 +17,7 @@ hook global WinSetOption filetype=go %{ set-option window static_words %opt{go_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group go-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group go-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group go-indent go-indent-on-new-line hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace @@ -103,10 +103,10 @@ define-command -hidden go-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } try %{ try %{ # line comment - execute-keys -draft k s ^\h*// + execute-keys -draft kx s ^\h*// } catch %{ # block comment execute-keys -draft /\* \*/ } @@ -114,9 +114,9 @@ define-command -hidden go-indent-on-new-line %~ # indent after lines with an unclosed { or ( try %< execute-keys -draft [c[({],[)}] \A[({][^\n]*\n[^\n]*\n?\z j > # indent after a switch's case/default statements - try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] + try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] } = ~ @@ -134,7 +134,7 @@ define-command -hidden go-indent-on-closing-curly-brace %[ define-command -hidden go-insert-comment-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } ] ] @@ -143,28 +143,28 @@ define-command -hidden go-insert-closing-delimiter-on-new-line %[ # Wisely add '}'. evaluate-commands -save-regs x %[ # Save previous line indent in register x. - try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft k ^x.*\{\h*\(?\h*$ j}iJ ^x\)?\h*\} + execute-keys -draft kx ^x.*\{\h*\(?\h*$ j}iJx ^x\)?\h*\} # Insert closing '}'. execute-keys -draft ox} # Delete trailing '}' on the line below the '{'. - execute-keys -draft Xs\}$d + execute-keys -draft xs\}$d ] ] # Wisely add ')'. evaluate-commands -save-regs x %[ # Save previous line indent in register x. - try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft k ^x.*\(\h*$ J}iJ ^x\) + execute-keys -draft kx ^x.*\(\h*$ J}iJx ^x\) # Insert closing ')'. execute-keys -draft ox) # Delete trailing ')' on the line below the '('. - execute-keys -draft Xs\)\h*\}?\h*$d + execute-keys -draft xs\)\h*\}?\h*$d ] ] ] diff --git a/rc/filetype/graphql.kak b/rc/filetype/graphql.kak index 83bfa811..85bf71de 100644 --- a/rc/filetype/graphql.kak +++ b/rc/filetype/graphql.kak @@ -74,7 +74,7 @@ add-highlighter shared/graphql/object/field/expand-fragment regex '\.\.\.(?=\w)' define-command -hidden graphql-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden graphql-indent-on-char %< @@ -91,9 +91,9 @@ define-command -hidden graphql-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : graphql-trim-indent } # indent after lines ending with opener token - try %< execute-keys -draft k [[{]\h*$ j > + try %< execute-keys -draft k x [[{]\h*$ j > # deindent closer token(s) when after cursor - try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > + try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > diff --git a/rc/filetype/haml.kak b/rc/filetype/haml.kak index e7bdb43d..492e78a9 100644 --- a/rc/filetype/haml.kak +++ b/rc/filetype/haml.kak @@ -54,13 +54,13 @@ add-highlighter shared/haml/code/ regex ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za- define-command -hidden haml-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden haml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K/\h* y gh j P } } } @@ -71,7 +71,7 @@ define-command -hidden haml-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : haml-trim-indent } # indent after lines beginning with : or - - try %{ execute-keys -draft k ^\h*[:-] j } + try %{ execute-keys -draft k x ^\h*[:-] j } } } diff --git a/rc/filetype/hare.kak b/rc/filetype/hare.kak index 47d0da41..3d59be12 100644 --- a/rc/filetype/hare.kak +++ b/rc/filetype/hare.kak @@ -95,22 +95,22 @@ provide-module hare %§ # preserve indentation on new lines try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j i ] + try %[ execute-keys -draft kx [{(]\h*$ j i ] # cleanup trailing white spaces on the previous line execute-keys -draft k :hare-trim-indent # indent after match/switch's case statements - try %[ execute-keys -draft k case\h.*=>\h*$ j ] + try %[ execute-keys -draft kx case\h.*=>\h*$ j ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] } } define-command -hidden hare-insert-on-new-line %{ evaluate-commands -draft -itersel %{ try %{ evaluate-commands -draft -save-regs '/"' %{ # copy the comment prefix - execute-keys -save-regs '' k s ^\h*\K//\h* y + execute-keys -save-regs '' k x s ^\h*\K//\h* y try %{ # paste the comment prefix - execute-keys j s ^\h* P + execute-keys x j x s ^\h* P } } } try %{ @@ -131,6 +131,6 @@ provide-module hare %§ define-command -hidden hare-trim-indent %{ evaluate-commands -draft -itersel %{ # remove trailing whitespace - try %{ execute-keys -draft s \h+$ d } + try %{ execute-keys -draft x s \h+$ d } } } § diff --git a/rc/filetype/haskell.kak b/rc/filetype/haskell.kak index 92a8b5a3..9beed993 100644 --- a/rc/filetype/haskell.kak +++ b/rc/filetype/haskell.kak @@ -101,13 +101,13 @@ add-highlighter shared/haskell/code/ regex \bderiving\b\s+(?:[A-Z]['\w]+|\([',\w define-command -hidden haskell-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden haskell-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak index e3a93505..5a9efaef 100644 --- a/rc/filetype/hbs.kak +++ b/rc/filetype/hbs.kak @@ -66,7 +66,7 @@ add-highlighter shared/hbs-file/html default-region ref html define-command -hidden hbs-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden hbs-indent-on-char %[ @@ -79,7 +79,7 @@ define-command -hidden hbs-indent-on-char %[ define-command -hidden hbs-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/\h* y j p } + try %{ execute-keys -draft k x s ^\h*\K/\h* y j p } } } @@ -90,7 +90,7 @@ define-command -hidden hbs-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : hbs-trim-indent } # indent after lines beginning with : or - - try %{ execute-keys -draft k ^\h*[:-] j } + try %{ execute-keys -draft k x ^\h*[:-] j } } } diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak index 33e65a9b..8a68c69f 100644 --- a/rc/filetype/html.kak +++ b/rc/filetype/html.kak @@ -64,7 +64,7 @@ add-highlighter shared/html/tag/base/ regex <(!DOCTYPE(\h+\w+)+) 1:meta define-command -hidden html-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden html-indent-on-greater-than %[ @@ -81,7 +81,7 @@ define-command -hidden html-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : html-trim-indent } # indent after lines ending with opening tag except when it starts with a closing tag - try %{ execute-keys -draft k (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ j^\s*/ } } + try %{ execute-keys -draft k x (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ jx^\s*/ } } } ] diff --git a/rc/filetype/i3.kak b/rc/filetype/i3.kak index 73c3ed5f..deafb6c3 100644 --- a/rc/filetype/i3.kak +++ b/rc/filetype/i3.kak @@ -9,7 +9,7 @@ hook global WinSetOption filetype=i3 %[ require-module i3 # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group i3-insert i3-insert-on-new-line hook window InsertChar \n -group i3-indent i3-indent-on-new-line hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace @@ -71,7 +71,7 @@ add-highlighter shared/i3/code/ regex "client\.(focused_inactive|focused_tab_tit define-command -hidden i3-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy # comments prefix - try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + try %{ execute-keys -draft kx s ^\h*#\h* y jgh P } = ~ @@ -80,9 +80,9 @@ define-command -hidden i3-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { - try %[ execute-keys -draft k \{\h*$ j ] + try %[ execute-keys -draft kx \{\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } = ~ diff --git a/rc/filetype/java.kak b/rc/filetype/java.kak index bad48834..d252b4b6 100644 --- a/rc/filetype/java.kak +++ b/rc/filetype/java.kak @@ -11,7 +11,7 @@ hook global WinSetOption filetype=java %{ set-option window static_words %opt{java_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group java-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group java-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group java-insert java-insert-on-new-line hook window InsertChar \n -group java-indent java-indent-on-new-line hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace @@ -42,7 +42,7 @@ add-highlighter shared/java/code/ regex "(?k s ^\h*\K/{2,}\h* yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } ] define-command -hidden java-indent-on-new-line %~ @@ -50,17 +50,17 @@ define-command -hidden java-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements - try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] + try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # indent after keywords try %[ execute-keys -draft )MB \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] = ~ diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 2f55540a..1f39aa6a 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -43,7 +43,7 @@ provide-module javascript %§ define-command -hidden javascript-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft 1s^(\h+)$ d } + try %{ execute-keys -draft x 1s^(\h+)$ d } } define-command -hidden javascript-indent-on-char %< @@ -59,10 +59,10 @@ define-command -hidden javascript-insert-on-new-line %< try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix - execute-keys -save-regs '' k 1s^\h*(//+\h*) y + execute-keys -save-regs '' k x1s^\h*(//+\h*) y try %[ # if the previous comment isn't empty, create a new one - execute-keys ^\h*//+\h*$ js^\h*P + execute-keys x^\h*//+\h*$ jxs^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d @@ -71,24 +71,24 @@ define-command -hidden javascript-insert-on-new-line %< ] try %[ # if the previous line isn't within a comment scope, break - execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + execute-keys -draft kx ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space - execute-keys -draft k^\h*/\* + execute-keys -draft kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star - execute-keys -draft j^\h+\* + execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope - execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + execute-keys -draft kx^\h+\*\h+$ x1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* @@ -99,7 +99,7 @@ define-command -hidden javascript-insert-on-new-line %< # trim trailing whitespace on the previous line try %[ execute-keys -draft s\h+$ d ] # align the new star with the previous one - execute-keys K1s^[^*]*(\*)& + execute-keys Kx1s^[^*]*(\*)& ] > > @@ -113,31 +113,31 @@ define-command -hidden javascript-indent-on-new-line %< > catch %< # else if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + execute-keys -draft kx 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # remove previous empty lines resulting from the automatic indent - try %< execute-keys -draft k ^\h+$ Hd > + try %< execute-keys -draft k x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line - try %< execute-keys -draft k [{(]\h*$ j > + try %< execute-keys -draft k x [{(]\h*$ j > # indent after a label (works for case statements) - try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > + try %< execute-keys -draft k x s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace - try %< execute-keys -draft k s\)\h*(?://[^\n]+)?\n\z \ + try %< execute-keys -draft k x s\)\h*(?://[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > - try %< execute-keys -draft k s \belse\b\h*(?://[^\n]+)?\n\z \ + try %< execute-keys -draft k x s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end - try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ - K s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ + K x s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > - try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ - K s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ + K x s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # deindent closing brace(s) when after cursor - try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > + try %< execute-keys -draft x ^\h*[})] gh / [})] m 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %< diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index d337fc39..8ca7c2a3 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -43,7 +43,7 @@ add-highlighter shared/json/code/ regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][ define-command -hidden json-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden json-indent-on-char %< @@ -60,9 +60,9 @@ define-command -hidden json-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : json-trim-indent } # indent after lines ending with opener token - try %< execute-keys -draft k [[{]\h*$ j > + try %< execute-keys -draft k x [[{]\h*$ j > # deindent closer token(s) when after cursor - try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > + try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > diff --git a/rc/filetype/just.kak b/rc/filetype/just.kak index 64a977ba..a2aa1ef7 100644 --- a/rc/filetype/just.kak +++ b/rc/filetype/just.kak @@ -26,7 +26,7 @@ provide-module justfile %{ define-command -hidden justfile-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -37,9 +37,9 @@ define-command -hidden just-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing white spaces on previous line - try %{ execute-keys -draft k s \h+$ "_d } + try %{ execute-keys -draft kx s \h+$ "_d } # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*//\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index ccb84ec4..65ef2bdc 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -21,7 +21,7 @@ hook global WinSetOption filetype=kak %~ hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } @@ -96,7 +96,7 @@ add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b define-command -hidden kak-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } = ~ @@ -105,13 +105,13 @@ define-command -hidden kak-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with %\w*[^\s\w] - try %{ execute-keys -draft k \%\w*[^\s\w]$ j } + try %{ execute-keys -draft k x \%\w*[^\s\w]$ j } # deindent closing brace when after cursor - try %_ execute-keys -draft -itersel ^\h*([>)}\]]) gh / 1 m 1 _ + try %_ execute-keys -draft -itersel x ^\h*([>)}\]]) gh / 1 m 1 _ # deindent closing char(s) - try %{ execute-keys -draft -itersel ^\h*([^\s\w]) gh / 1 1 % \w*1$ 1 } + try %{ execute-keys -draft -itersel x ^\h*([^\s\w]) gh / 1 1 % \w*1$ 1 } = ~ diff --git a/rc/filetype/kotlin.kak b/rc/filetype/kotlin.kak index 37988089..14a8ff59 100644 --- a/rc/filetype/kotlin.kak +++ b/rc/filetype/kotlin.kak @@ -20,7 +20,7 @@ hook global WinSetOption filetype=kotlin %{ set-option window static_words %opt{kotlin_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group kotlin-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group kotlin-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group kotlin-indent kotlin-insert-on-new-line hook window InsertChar \n -group kotlin-indent kotlin-indent-on-new-line hook window InsertChar \{ -group kotlin-indent kotlin-indent-on-opening-curly-brace @@ -108,7 +108,7 @@ add-highlighter shared/kotlin/code/discolour regex ^(package|import)(?S)(.+) 2:d # ‾‾‾‾‾‾‾‾ define-command -hidden kotlin-insert-on-new-line %[ # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } ] define-command -hidden kotlin-indent-on-new-line %~ @@ -116,19 +116,19 @@ define-command -hidden kotlin-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a pattern match on when/where statements - try %[ execute-keys -draft k ^\h*(when|where).*$ j ] + try %[ execute-keys -draft kx ^\h*(when|where).*$ j ] # indent after term on an expression - try %[ execute-keys -draft k =\h*?$ j ] + try %[ execute-keys -draft kx =\h*?$ j ] # indent after keywords try %[ execute-keys -draft )MB \A(catch|do|else|for|if|try|while)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] > ~ diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak index 3a775311..73ee97ff 100644 --- a/rc/filetype/latex.kak +++ b/rc/filetype/latex.kak @@ -80,27 +80,27 @@ add-highlighter shared/latex/content/ regex '((? 1s^(\h+)$ d } + try %{ execute-keys x 1s^(\h+)$ d } } } define-command -hidden latex-indent-newline %( evaluate-commands -no-hooks -draft -itersel %( # copy '%' comment prefix and following white spaces - try %{ execute-keys -draft k s^\h*%\h* y jgh P } + try %{ execute-keys -draft kx s^\h*%\h* y jgh P } # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s\h+$ d } + try %{ execute-keys -draft kx s\h+$ d } # indent after line ending with { - try %( execute-keys -draft k \{$ j ) + try %( execute-keys -draft kx \{$ j ) # deindent closing brace(s) when after cursor - try %( execute-keys -draft ^\h*\} gh / \} m 1 ) + try %( execute-keys -draft x ^\h*\} gh / \} m 1 ) # indent after line ending with \begin{...}[...]{...}, with multiple # sets of arguments possible try %( execute-keys -draft \ - k \ + kx \ \\begin\h*\{[^\}]+\}(\h|\[.*\]|\{.*\})*$ \ j ) @@ -110,7 +110,7 @@ define-command -hidden latex-indent-newline %( define-command -hidden latex-indent-closing-brace %( evaluate-commands -no-hooks -draft -itersel %( # Align lone } with matching bracket - try %( execute-keys -draft _ \A\}\z m1 ) + try %( execute-keys -draft x_ \A\}\z m1 ) # Align \end{...} with corresponding \begin{...} try %( execute-keys -draft h 1s\\end\h*\{([^\}]+)\}\z \ @@ -124,12 +124,12 @@ define-command -hidden latex-insert-on-new-line %( # Wisely add "\end{...}". evaluate-commands -save-regs xz %( # Save previous line indent in register x. - try %( execute-keys -draft ks^\h+"xy ) catch %( reg x '' ) + try %( execute-keys -draft kxs^\h+"xy ) catch %( reg x '' ) # Save item of begin in register z. - try %( execute-keys -draft ks\{.*\}"zy ) catch %( reg z '' ) + try %( execute-keys -draft kxs\{.*\}"zy ) catch %( reg z '' ) try %( # Validate previous line and that it is not closed yet. - execute-keys -draft k ^x\h*\\begin\{.*\} J}iJ ^x(\\end\z\}) + execute-keys -draft kx ^x\h*\\begin\{.*\} J}iJx ^x(\\end\z\}) # Auto insert "\end{...}". execute-keys -draft ox\endz ) diff --git a/rc/filetype/ledger.kak b/rc/filetype/ledger.kak index 5ebe489f..0bd52ea0 100644 --- a/rc/filetype/ledger.kak +++ b/rc/filetype/ledger.kak @@ -129,14 +129,14 @@ define-command -hidden ledger-indent-on-new-line %[ # preserve previous line indent try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line - try %[ execute-keys -draft k s \h+$ d ] + try %[ execute-keys -draft k x s \h+$ d ] # indent after the first line of a transaction - try %[ execute-keys -draft k ^[0-9] j ] + try %[ execute-keys -draft kx ^[0-9] j ] ] ] define-command -hidden ledger-trim-indent %{ - try %{ execute-keys -draft s ^\h+$ d } + try %{ execute-keys -draft x s ^\h+$ d } } ] diff --git a/rc/filetype/lisp.kak b/rc/filetype/lisp.kak index 2c3594a0..153acbcf 100644 --- a/rc/filetype/lisp.kak +++ b/rc/filetype/lisp.kak @@ -48,7 +48,7 @@ add-highlighter shared/lisp/code/ regex (\b\d+)?\.\d+([eEsSfFdDlL]\d+)?\b 0:valu define-command -hidden lisp-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } declare-option \ diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 1dd0178a..b1bcf4ea 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -87,7 +87,7 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl define-command -hidden lua-trim-indent %[ # remove trailing whitespaces - try %[ execute-keys -draft -itersel s \h+$ d ] + try %[ execute-keys -draft -itersel x s \h+$ d ] ] define-command -hidden lua-indent-on-char %[ @@ -112,7 +112,7 @@ define-command -hidden lua-indent-on-new-line %[ # - or contains an unclosed function expression, # - or ends with an enclosed '(' or '{' try %[ execute-keys -draft \ - K \ + Kx \ \A\h*-- \ \A[^\n]*\b(end|until)\b \ \A(\h*\b(do|else|elseif|for|function|if|repeat|while)\b|[^\n]*[({]$|[^\n]*\bfunction\b\h*[(]) \ @@ -124,23 +124,23 @@ define-command -hidden lua-indent-on-new-line %[ define-command -hidden lua-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy -- comment prefix and following white spaces - try %[ execute-keys -draft ks^\h*\K--\h* y gh j P ] + try %[ execute-keys -draft kxs^\h*\K--\h* y gh j x P ] # wisely add end structure evaluate-commands -save-regs x %[ # save previous line indent in register x - try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # check that starts with a block keyword that is not closed on the same line execute-keys -draft \ - k \ + kx \ ^\h*\b(else|elseif|do|for|function|if|while)\b|[^\n]\bfunction\b\h*[(] \ \bend\b # check that the block is empty and is not closed on a different line - execute-keys -draft i ^[^\n]+\n[^\n]+\n j ^x\b(else|elseif|end)\b + execute-keys -draft i ^[^\n]+\n[^\n]+\n jx ^x\b(else|elseif|end)\b # auto insert end execute-keys -draft oxend # auto insert ) for anonymous function - execute-keys -draft k\([^)\n]*function\bjjA) + execute-keys -draft kx\([^)\n]*function\bjjA) ] ] ] diff --git a/rc/filetype/makefile.kak b/rc/filetype/makefile.kak index 2026c745..c668d696 100644 --- a/rc/filetype/makefile.kak +++ b/rc/filetype/makefile.kak @@ -53,7 +53,7 @@ evaluate-commands %sh{ define-command -hidden makefile-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -64,11 +64,11 @@ define-command -hidden makefile-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } ## If the line above is a target indent with a tab - try %{ execute-keys -draft Z k ^\S.*?(::|:|!)\s z i } + try %{ execute-keys -draft Z kx ^\S.*?(::|:|!)\s z i } # cleanup trailing white space son previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # indent after some keywords - try %{ execute-keys -draft Z k ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b z } + try %{ execute-keys -draft Z kx ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b z } } } diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index e5ed8d58..3aaf1c45 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -102,14 +102,14 @@ add-highlighter shared/markdown/inline/text/ regex "\H( {2,})$" 1:+r@meta define-command -hidden markdown-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden markdown-insert-on-new-line %{ - try %{ execute-keys -draft -itersel k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } + try %{ execute-keys -draft -itersel k x s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } } define-command -hidden markdown-indent-on-new-line %{ @@ -117,7 +117,7 @@ define-command -hidden markdown-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } # remove trailing white spaces - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } } } diff --git a/rc/filetype/mercury.kak b/rc/filetype/mercury.kak index 4292d146..7992c889 100644 --- a/rc/filetype/mercury.kak +++ b/rc/filetype/mercury.kak @@ -16,7 +16,7 @@ hook global WinSetOption filetype=mercury %{ hook window InsertChar \n -group mercury-insert mercury-insert-on-new-line hook window InsertChar \n -group mercury-indent mercury-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group mercury-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group mercury-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window mercury-.+ } } @@ -97,7 +97,7 @@ evaluate-commands %sh{ define-command -hidden mercury-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '%' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\%\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\%\h* y gh j P } } } @@ -113,11 +113,11 @@ define-command -hidden mercury-indent-on-new-line %< # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with :- - try %{ execute-keys -draft k :-$ j } + try %{ execute-keys -draft k x :-$ j } # deindent closing brace/bracket when after cursor - try %< execute-keys -draft ^\h*[}\])] gh / [}\])] m 1 > + try %< execute-keys -draft x ^\h*[}\])] gh / [}\])] m 1 > > > diff --git a/rc/filetype/moon.kak b/rc/filetype/moon.kak index 6f5137ee..fcd7c130 100644 --- a/rc/filetype/moon.kak +++ b/rc/filetype/moon.kak @@ -80,7 +80,7 @@ define-command moon-alternative-file -docstring 'Jump to the alternate file (imp define-command -hidden moon-trim-indent %{ evaluate-commands -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -89,18 +89,18 @@ define-command -hidden moon-trim-indent %{ define-command -hidden moon-indent-on-char %{ evaluate-commands -draft -itersel %{ # align _else_ statements to start - try %{ execute-keys -draft ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } + try %{ execute-keys -draft x ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } # align _when_ to _switch_ then indent - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) } + try %{ execute-keys -draft x ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) } # align _catch_ and _finally_ to _try_ - try %{ execute-keys -draft ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } + try %{ execute-keys -draft x ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } } } define-command -hidden moon-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } @@ -111,9 +111,9 @@ define-command -hidden moon-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : moon-trim-indent } # indent after start structure - try %{ execute-keys -draft k ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ j } + try %{ execute-keys -draft k x ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ j } # deindent after return statements - try %{ execute-keys -draft k ^ \h * (break|return) \b j } + try %{ execute-keys -draft k x ^ \h * (break|return) \b j } } } diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 954b3033..916b9d19 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -19,7 +19,7 @@ hook global WinSetOption filetype=nim %{ hook window InsertChar \n -group nim-insert nim-insert-on-new-line hook window InsertChar \n -group nim-indent nim-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } } @@ -114,7 +114,7 @@ add-highlighter shared/nim/code/ regex %{'(\\([rcnlftvabe\\"']|0*[12]?\d?\d|x[0- define-command -hidden nim-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ exec -draft k s ^\h*#\h* y jgh P } + try %{ exec -draft k x s ^\h*#\h* y jgh P } } } @@ -123,9 +123,9 @@ define-command -hidden nim-indent-on-new-line %{ # preserve previous line indent try %{ exec -draft K } # cleanup trailing whitespaces from previous line - try %{ exec -draft k s \h+$ d } + try %{ exec -draft k x s \h+$ d } # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' - try %{ exec -draft k (:|=|\b(?:enum|tuple|object|const|let|var|import|export|type))$ j } + try %{ exec -draft k x (:|=|\b(?:enum|tuple|object|const|let|var|import|export|type))$ j } } } diff --git a/rc/filetype/ninja.kak b/rc/filetype/ninja.kak index 6ae51148..b4b5ea6e 100644 --- a/rc/filetype/ninja.kak +++ b/rc/filetype/ninja.kak @@ -20,7 +20,7 @@ hook global WinSetOption filetype=ninja %{ hook window InsertChar \n -group ninja-insert ninja-insert-on-new-line hook window InsertChar \n -group ninja-indent ninja-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group ninja-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group ninja-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ninja-.+ } } @@ -82,13 +82,13 @@ evaluate-commands %sh{ define-command -hidden ninja-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden ninja-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } diff --git a/rc/filetype/nix.kak b/rc/filetype/nix.kak index 3eecc4d9..35e5e4eb 100644 --- a/rc/filetype/nix.kak +++ b/rc/filetype/nix.kak @@ -91,7 +91,7 @@ add-highlighter shared/nix/code/ regex '([^:/?#\s]+):([^#(){}\[\]";`|\s\\]+)' 0: define-command -hidden nix-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden nix-indent-on-char %< @@ -104,7 +104,7 @@ define-command -hidden nix-indent-on-char %< define-command -hidden nix-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } > > @@ -115,9 +115,9 @@ define-command -hidden nix-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : nix-trim-indent } # indent after lines beginning / ending with opener token - try %_ execute-keys -draft k ^\h*[[{]|[[{]$ j _ + try %_ execute-keys -draft k x ^\h*[[{]|[[{]$ j _ # deindent closer token(s) when after cursor - try %_ execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 _ + try %_ execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 _ > > diff --git a/rc/filetype/pascal.kak b/rc/filetype/pascal.kak index 8c70210b..eae45772 100644 --- a/rc/filetype/pascal.kak +++ b/rc/filetype/pascal.kak @@ -192,7 +192,7 @@ EOF define-command -hidden pascal-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -203,9 +203,9 @@ define-command -hidden pascal-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after certain keywords - try %{ execute-keys -draft k(?i)(asm|begin|const|else|except|exports|finalization|finally|label|of|otherwise|private|property|public|protected|published|record|repeat|resourcestring|threadvar|try|type|uses|var|:)\h*$j } + try %{ execute-keys -draft kx(?i)(asm|begin|const|else|except|exports|finalization|finally|label|of|otherwise|private|property|public|protected|published|record|repeat|resourcestring|threadvar|try|type|uses|var|:)\h*$j } } } § diff --git a/rc/filetype/perl.kak b/rc/filetype/perl.kak index cfa8067d..699b94d4 100644 --- a/rc/filetype/perl.kak +++ b/rc/filetype/perl.kak @@ -17,7 +17,7 @@ hook global WinSetOption filetype=perl %{ set-option window static_words %opt{perl_static_words} # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange pop:insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window ModeChange pop:insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group perl-insert perl-insert-on-new-line hook window InsertChar \n -group perl-indent perl-indent-on-new-line hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace @@ -110,7 +110,7 @@ add-highlighter shared/perl/code/ regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATO define-command -hidden perl-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy # comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* yP } + try %{ execute-keys -draft kx s ^\h*\K#\h* yP } = ~ @@ -119,17 +119,17 @@ define-command -hidden perl-indent-on-new-line %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] + try %[ execute-keys -draft kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements - try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] + try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] + try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] = ~ diff --git a/rc/filetype/php.kak b/rc/filetype/php.kak index 560daa01..62ba6ddd 100644 --- a/rc/filetype/php.kak +++ b/rc/filetype/php.kak @@ -72,7 +72,7 @@ add-highlighter shared/php-file/php region '<\?(php)?' '\?>' ref php define-command -hidden php-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden php-indent-on-char %< @@ -85,9 +85,9 @@ define-command -hidden php-indent-on-char %< define-command -hidden php-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments or docblock * prefix and following white spaces - try %{ execute-keys -draft s [^/] k s ^\h*\K(?://|[*][^/])\h* y gh j P } + try %{ execute-keys -draft s [^/] k x s ^\h*\K(?://|[*][^/])\h* y gh j P } # append " * " on lines starting a multiline /** or /* comment - try %{ execute-keys -draft k s ^\h*/[*][* ]? j gi i * } + try %{ execute-keys -draft k x s ^\h*/[*][* ]? j gi i * } > > @@ -98,9 +98,9 @@ define-command -hidden php-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : php-trim-indent } # indent after lines beginning / ending with opener token - try %_ execute-keys -draft k ^\h*[[{]|[[{]$ j _ + try %_ execute-keys -draft k x ^\h*[[{]|[[{]$ j _ # deindent closer token(s) when after cursor - try %_ execute-keys -draft ^\h*[})] gh / [})] m 1 _ + try %_ execute-keys -draft x ^\h*[})] gh / [})] m 1 _ > > diff --git a/rc/filetype/pony.kak b/rc/filetype/pony.kak index 406c7dbb..592fb943 100644 --- a/rc/filetype/pony.kak +++ b/rc/filetype/pony.kak @@ -19,7 +19,7 @@ hook global WinSetOption filetype=pony %{ hook window InsertChar \n -group pony-insert pony-insert-on-new-line hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } @@ -93,7 +93,7 @@ define-command -hidden pony-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with : try %{ execute-keys -draft k x (\b(?:do|try|then|else)|:|=>)$ j } # else, end are always de-indented diff --git a/rc/filetype/protobuf.kak b/rc/filetype/protobuf.kak index ba0c52a3..828105f7 100644 --- a/rc/filetype/protobuf.kak +++ b/rc/filetype/protobuf.kak @@ -69,7 +69,7 @@ evaluate-commands %sh{ define-command -hidden protobuf-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -80,13 +80,13 @@ define-command -hidden protobuf-indent-on-newline %~ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { - try %[ execute-keys -draft k \{\h*$ j ] + try %[ execute-keys -draft kx \{\h*$ j ] # cleanup trailing white spaces on the previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } # copy // comments prefix - try %{ execute-keys -draft k s ^\h*\K/{2,}(\h*(?=\S))? yP } + try %{ execute-keys -draft kx s ^\h*\K/{2,}(\h*(?=\S))? yP } # deindent closing brace(s) when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ~ diff --git a/rc/filetype/pug.kak b/rc/filetype/pug.kak index 9bb83d72..f9520bbe 100644 --- a/rc/filetype/pug.kak +++ b/rc/filetype/pug.kak @@ -62,7 +62,7 @@ add-highlighter shared/pug/code/ regex ((?:\.[A-Za-z][A-Za-z0-9_-]* define-command -hidden pug-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden pug-indent-on-new-line %{ @@ -72,7 +72,7 @@ define-command -hidden pug-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : pug-trim-indent } # copy '//', '|', '-' or '(!)=' prefix and following whitespace - try %{ execute-keys -draft k s ^\h*\K[/|!=-]{1,2}\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K[/|!=-]{1,2}\h* y gh j P } # indent unless we copied something above try %{ execute-keys -draft b s \S g l } } diff --git a/rc/filetype/purescript.kak b/rc/filetype/purescript.kak index 12b26283..8945ae60 100644 --- a/rc/filetype/purescript.kak +++ b/rc/filetype/purescript.kak @@ -94,13 +94,13 @@ add-highlighter shared/purescript/code/ regex ^\s*(?:where\s+|let\s+|default\s+) define-command -hidden purescript-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden purescript-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index d05338d3..ff60297a 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -19,7 +19,7 @@ hook global WinSetOption filetype=python %{ hook window InsertChar \n -group python-insert python-insert-on-new-line hook window InsertChar \n -group python-indent python-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } } @@ -149,7 +149,7 @@ add-highlighter shared/python/code/ regex ^\h*(?:from|import)\h+(\S+) 1:module define-command -hidden python-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*#\h* y jgh P } + try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } } } @@ -158,11 +158,11 @@ define-command -hidden python-indent-on-new-line %< # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with : - try %{ execute-keys -draft k :$ ^\h*# j } + try %{ execute-keys -draft k x :$ ^\h*# j } # deindent closing brace/bracket when after cursor (for arrays and dictionaries) - try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > + try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > diff --git a/rc/filetype/r.kak b/rc/filetype/r.kak index 0a7bade1..30d15430 100644 --- a/rc/filetype/r.kak +++ b/rc/filetype/r.kak @@ -56,7 +56,7 @@ add-highlighter shared/r/code/ regex (?<=[\w\s\d'"_)])(\$|@|\^|-|\+|%[^%^\n]+%|\ define-command -hidden r-trim-indent %{ # remove the line if it's empty when leaving the insert mode - try %{ execute-keys -draft 1s^(\h+)$ d } + try %{ execute-keys -draft x 1s^(\h+)$ d } } define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel %< @@ -64,26 +64,26 @@ define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel try %< # if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?:#[^\n]+)?\n\z mJ 1 + execute-keys -draft kx 1s(\))(\h+\w+)*\h*(\;\h*)?(?:#[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # remove previous empty lines resulting from the automatic indent - try %< execute-keys -draft k ^\h+$ Hd > + try %< execute-keys -draft k x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line - try %< execute-keys -draft k s[{(]\h*$ j > + try %< execute-keys -draft k x s[{(]\h*$ j > # indent after a statement not followed by an opening brace - try %< execute-keys -draft k s\)\h*(?:#[^\n]+)?\n\z \ + try %< execute-keys -draft k x s\)\h*(?:#[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > - try %< execute-keys -draft k s \belse\b\h*(?:#[^\n]+)?\n\z \ + try %< execute-keys -draft k x s \belse\b\h*(?:#[^\n]+)?\n\z \ j > # deindent after a single line statement end - try %< execute-keys -draft K \;\h*(#[^\n]+)?$ \ - K s\)(\h+\w+)*\h*(#[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(#[^\n]+)?$ \ + K x s\)(\h+\w+)*\h*(#[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > - try %< execute-keys -draft K \;\h*(#[^\n]+)?$ \ - K s \belse\b\h*(?:#[^\n]+)?\n([^\n]*\n){2}\z \ + try %< execute-keys -draft K x \;\h*(#[^\n]+)?$ \ + K x s \belse\b\h*(?:#[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line @@ -120,10 +120,10 @@ define-command -hidden r-insert-on-newline %[ evaluate-commands -itersel -draft try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix - execute-keys -save-regs '' k 1s^\h*(#+\h*) y + execute-keys -save-regs '' k x1s^\h*(#+\h*) y try %[ # if the previous comment isn't empty, create a new one - execute-keys ^\h*#+\h*$ js^\h*P + execute-keys x^\h*#+\h*$ jxs^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak index f873d63c..e0a77db2 100644 --- a/rc/filetype/ragel.kak +++ b/rc/filetype/ragel.kak @@ -50,7 +50,7 @@ add-highlighter shared/ragel/code/ regex \b(action|alnum|alpha|any|ascii|case|cn define-command -hidden ragel-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden ragel-indent-on-char %< @@ -64,7 +64,7 @@ define-command -hidden ragel-indent-on-char %< define-command -hidden ragel-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy _#_ comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } > > @@ -75,9 +75,9 @@ define-command -hidden ragel-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : ragel-trim-indent } # indent after lines ending with opener token - try %< execute-keys -draft k [[{(*]$ j > + try %< execute-keys -draft k x [[{(*]$ j > # align closer token to its opener when after cursor - try %< execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 > + try %< execute-keys -draft x ^\h*[})\]] gh / [})\]] m 1 > > > diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index a950da19..0a57264a 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -144,7 +144,7 @@ define-command ruby-alternative-file -docstring 'Jump to the alternate file (imp define-command -hidden ruby-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -153,10 +153,10 @@ define-command -hidden ruby-trim-indent %{ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start - try %{ execute-keys -draft ^ \h * (else) $ i ^ \h * (if|case) 1 } - try %{ execute-keys -draft ^ \h * (elsif) $ i ^ \h * (if) 1 } - try %{ execute-keys -draft ^ \h * (when) $ i ^ \h * (case) 1 } - try %{ execute-keys -draft ^ \h * (rescue) $ i ^ \h * (begin|def) 1 } + try %{ execute-keys -draft x ^ \h * (else) $ i ^ \h * (if|case) 1 } + try %{ execute-keys -draft x ^ \h * (elsif) $ i ^ \h * (if) 1 } + try %{ execute-keys -draft x ^ \h * (when) $ i ^ \h * (case) 1 } + try %{ execute-keys -draft x ^ \h * (rescue) $ i ^ \h * (begin|def) 1 } } } @@ -167,23 +167,23 @@ define-command -hidden ruby-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : ruby-trim-indent } # indent after start structure - try %{ execute-keys -draft k ^ \h * (begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|)) [^0-9A-Za-z_!?] j } + try %{ execute-keys -draft k x ^ \h * (begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|)) [^0-9A-Za-z_!?] j } } } define-command -hidden ruby-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y jgi P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y jgi P } # wisely add end structure evaluate-commands -save-regs x %[ - try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } + try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block - execute-keys -draft k ^x(begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] + execute-keys -draft kx ^x(begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] # Check that we do not already have an end for this indent level which is first set via `ruby-indent-on-new-line` hook - execute-keys -draft }i J ^x(end|else|elsif|rescue|when)[^0-9A-Za-z_!?] + execute-keys -draft }i J x ^x(end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 9d20a46b..26e110e4 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -109,7 +109,7 @@ add-highlighter shared/rust/code/std_traits regex \b(Copy|Send|Sized define-command -hidden rust-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden rust-indent-on-new-line %~ @@ -118,10 +118,10 @@ define-command -hidden rust-indent-on-new-line %~ try %[ # line comment evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix - execute-keys -save-regs '' k s ^\h*//[!/]{0,2}\h* y + execute-keys -save-regs '' k x s ^\h*//[!/]{0,2}\h* y try %[ # if the previous comment isn't empty, create a new one - execute-keys ^\h*//[!/]{0,2}$ js^\h*P + execute-keys x^\h*//[!/]{0,2}$ jxs^\h*P ] catch %[ # TODO figure out a way to not delete empty comment in current line # if there is no space and text in the previous comment, remove it completely @@ -130,24 +130,24 @@ define-command -hidden rust-indent-on-new-line %~ ] ] catch %[ # block comment # if the previous line isn't within a comment scope, break - execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + execute-keys -draft kx ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space - execute-keys -draft k^\h*/\* + execute-keys -draft kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star - execute-keys -draft j^\h+\* + execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope - execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + execute-keys -draft kx^\h+\*\h+$ x1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* @@ -158,29 +158,29 @@ define-command -hidden rust-indent-on-new-line %~ # trim trailing whitespace on the previous line try %[ execute-keys -draft s\h+$ d ] # align the new star with the previous one - execute-keys K1s^[^*]*(\*)& + execute-keys Kx1s^[^*]*(\*)& ] } catch %` # re-indent previous line if it starts with where to match previous block # string literal parsing within extern does not handle escape - try %% execute-keys -draft k ^\h*where\b hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union)))\b 1 % + try %% execute-keys -draft k x ^\h*where\b hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union)))\b 1 % # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with [{([].+ and move first parameter to own line try %< execute-keys -draft [c[({[],[)}\]] \A[({[][^\n]+\n[^\n]*\n?\z L i > # indent after non-empty lines not starting with operator and not ending with , or ; or { # XXX simplify this into a single without s - try %< execute-keys -draft k s [^\h].+ \A[-+*/&|^})#] [,{](\h*/[/*].*|)$ j > + try %< execute-keys -draft k x s [^\h].+ \A[-+*/&|^})#] [,{](\h*/[/*].*|)$ j > # indent after lines ending with { - try %+ execute-keys -draft k \{$ j + + try %+ execute-keys -draft k x \{$ j + # dedent after lines starting with . and ending with } or ) or , or ; or .await (} or ) or .await maybe with ?) - try %_ execute-keys -draft k ^\h*\. ([,]|(([})]|\.await)\?*))\h*$ j _ + try %_ execute-keys -draft k x ^\h*\. ([,]|(([})]|\.await)\?*))\h*$ j _ # dedent after lines ending with " => {}" - part of empty match - try %# execute-keys -draft k \ =>\ \{\}\h*$ j # + try %# execute-keys -draft k x \ =>\ \{\}\h*$ j # # align to opening curly brace or paren when newline is inserted before a single closing try %< execute-keys -draft ^\h*[)}] h m 1 > # todo dedent additional unmatched parenthesis - # try %& execute-keys -draft k s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{ + # try %& execute-keys -draft k x s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{ # count previous selections length # printf "j $(echo $kak_selections_length | wc -w) " # } & @@ -195,7 +195,7 @@ define-command -hidden rust-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] # dedent standalone { after impl and related block without any { in between - try %@ execute-keys -draft hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union))|if|for)\b \{ ll ^\h*\{$ @ + try %@ execute-keys -draft hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union))|if|for)\b \{ ll x ^\h*\{$ @ ~ ] diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index 9c5869b1..5f2cce08 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -53,7 +53,7 @@ add-highlighter shared/sass/code/ regex !important 0:keyword define-command -hidden sass-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden sass-indent-on-closing-brace %< @@ -66,7 +66,7 @@ define-command -hidden sass-indent-on-closing-brace %< define-command -hidden sass-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K/{2,}\h* y gh j P } > > @@ -77,9 +77,9 @@ define-command -hidden sass-indent-on-new-line %< # filter previous line try %{ execute-keys -draft k : sass-trim-indent } # avoid indent after properties and comments - try %{ execute-keys -draft k [:/] j } + try %{ execute-keys -draft k x [:/] j } # deindent closing brace when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] > > diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak index 626058d0..0822a016 100644 --- a/rc/filetype/scala.kak +++ b/rc/filetype/scala.kak @@ -57,13 +57,13 @@ add-highlighter shared/scala/code/ regex (\[|\]|=>|<:|:>|=:=|::|&&|\|\|) 0:opera define-command -hidden scala-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden scala-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* yP } + try %{ execute-keys -draft kx s ^\h*\K#\h* yP } ] ] @@ -74,9 +74,9 @@ define-command -hidden scala-indent-on-new-line %[ # filter previous line try %[ execute-keys -draft k : scala-trim-indent ] # indent after lines ending with { - try %[ execute-keys -draft k \{$ j ] + try %[ execute-keys -draft k x \{$ j ] # deindent closing brace when after cursor - try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] + try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index f853199c..7a284c84 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -71,7 +71,7 @@ add-highlighter shared/sh/double_string/expansion regex (? s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } # This is at best an approximation, since shell syntax is very complex. @@ -85,7 +85,7 @@ define-command -hidden sh-trim-indent %{ define-command -hidden sh-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } ] ] @@ -120,11 +120,11 @@ define-command -hidden sh-indent-on-new-line %¶ # done # # indent after do - try %{ execute-keys -draft k \bdo$ j } + try %{ execute-keys -draft k x \bdo$ j } # copy the indentation of the matching for/when - matching on the do # statement, so we don't need to duplicate this for the two loop # structures. - try %{ execute-keys -draft k \bdone$ gh [c\bdo\b,\bdone\b 1 j K } + try %{ execute-keys -draft k x \bdone$ gh [c\bdo\b,\bdone\b x 1 j K } # Indent if/then/else syntax, e.g.: # if [ $foo = $bar ]; then @@ -142,11 +142,11 @@ define-command -hidden sh-indent-on-new-line %¶ # fi # # indent after then - try %{ execute-keys -draft k \bthen$ j } + try %{ execute-keys -draft k x \bthen$ j } # copy the indentation of the matching if - try %{ execute-keys -draft k \bfi$ gh [c\bif\b,\bfi\b 1 j K } + try %{ execute-keys -draft k x \bfi$ gh [c\bif\b,\bfi\b x 1 j K } # copy the indentation of the matching if, and then re-indent afterwards - try %{ execute-keys -draft k \belse$ gh [c\bif\b,\bfi\b 1 j K j } + try %{ execute-keys -draft k x \belse$ gh [c\bif\b,\bfi\b x 1 j K j } # Indent case syntax, e.g.: # case "$foo" in @@ -166,13 +166,13 @@ define-command -hidden sh-indent-on-new-line %¶ # esac # # indent after in - try %{ execute-keys -draft k \bin$ j } + try %{ execute-keys -draft k x \bin$ j } # copy the indentation of the matching case - try %{ execute-keys -draft k \besac$ gh [c\bcase\b,\besac\b 1 j K } + try %{ execute-keys -draft k x \besac$ gh [c\bcase\b,\besac\b x 1 j K } # indent after ) - try %{ execute-keys -draft k ^\s*\(?[^(]+[^)]\)$ j } + try %{ execute-keys -draft k x ^\s*\(?[^(]+[^)]\)$ j } # deindent after ;; - try %{ execute-keys -draft k ^\s*\;\;$ j } + try %{ execute-keys -draft k x ^\s*\;\;$ j } # Indent compound commands as logical blocks, e.g.: # { @@ -194,11 +194,11 @@ define-command -hidden sh-indent-on-new-line %¶ # white space (including a newline), though technically it can also be # ';'. Only vertical white space makes sense in this context, though, # since the syntax denotes a logical block, not a simple compound command. - try %= execute-keys -draft k (\s|^)\{$ j = + try %= execute-keys -draft k x (\s|^)\{$ j = # deindent closing } - try %= execute-keys -draft k ^\s*\}$ j K = + try %= execute-keys -draft k x ^\s*\}$ j K = # deindent closing } when after cursor - try %= execute-keys -draft ^\h*\} gh / \} m 1 = + try %= execute-keys -draft x ^\h*\} gh / \} m 1 = @ ¶ diff --git a/rc/filetype/taskpaper.kak b/rc/filetype/taskpaper.kak index 94ab1b81..ece6664e 100644 --- a/rc/filetype/taskpaper.kak +++ b/rc/filetype/taskpaper.kak @@ -43,7 +43,7 @@ add-highlighter shared/taskpaper/ regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) define-command -hidden taskpaper-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ - execute-keys + execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } @@ -54,9 +54,9 @@ define-command -hidden taskpaper-indent-on-new-line %{ # preserve previous line indent try %{ execute-keys -draft K } ## If the line above is a project indent with a tab - try %{ execute-keys -draft Z k ^\h*([^:\n]+): z i } + try %{ execute-keys -draft Z kx ^\h*([^:\n]+): z i } # cleanup trailing white spaces on previous line - try %{ execute-keys -draft k s \h+$ d } + try %{ execute-keys -draft kx s \h+$ d } } } diff --git a/rc/filetype/toml.kak b/rc/filetype/toml.kak index bc78b0dd..d02e0740 100644 --- a/rc/filetype/toml.kak +++ b/rc/filetype/toml.kak @@ -54,13 +54,13 @@ add-highlighter shared/toml/code/ regex \ define-command -hidden toml-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden toml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy # comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } diff --git a/rc/filetype/twig.kak b/rc/filetype/twig.kak index 6fcfeeb4..2f5ef184 100644 --- a/rc/filetype/twig.kak +++ b/rc/filetype/twig.kak @@ -80,7 +80,7 @@ define-command -hidden twig-insert-on-new-line %[ evaluate-commands -draft -itersel %/ execute-keys try %[ - execute-keys -draft k^\h*\{\[%#\{\]\h+$ + execute-keys -draft kx^\h*\{\[%#\{\]\h+$ execute-keys -draft jghd ] / diff --git a/rc/filetype/vhdl.kak b/rc/filetype/vhdl.kak index 048ac580..ddb9e5ee 100644 --- a/rc/filetype/vhdl.kak +++ b/rc/filetype/vhdl.kak @@ -13,7 +13,7 @@ hook global WinSetOption filetype=vhdl %[ hook -group vhdl-indent window InsertChar \) vhdl-indent-on-closing-parenthesis hook -group vhdl-insert window InsertChar \n vhdl-insert-on-new-line # Cleanup trailing whitespaces on current line insert end. - hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft s ^\h+$ d ] ] + hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft x s ^\h+$ d ] ] hook -once -always window WinSetOption filetype=.* %[ remove-hooks window vhdl-.+ ] ] @@ -168,13 +168,13 @@ define-command -hidden vhdl-insert-on-new-line %[ # Copy '--' comment prefix and following white spaces. try %[ # is needed because of "Preserve previous line indent" command. - try %[ execute-keys -draft k s ^\h*--\h* y j gh P ] + try %[ execute-keys -draft k x s ^\h*--\h* y j gh P ] ] ] evaluate-commands -save-regs x %[ # Save previous line indent in register x. - try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] # All "wisely add" commands share the same concept. # Only "end if" has extra comments. @@ -182,170 +182,170 @@ define-command -hidden vhdl-insert-on-new-line %[ evaluate-commands %[ try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft k ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) }i ^x(?i)end\b + execute-keys -draft kx ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) }ix ^x(?i)end\b # Don't add for "if ... generate", it requires "end generate;". - execute-keys -draft k (?i)\bgenerate\b + execute-keys -draft kx (?i)\bgenerate\b execute-keys -draft oxendif ] ] # Wisely add "end generate;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i).*\bgenerate$ }i ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i).*\bgenerate$ }ix ^x(?i)(begin|end) # Don't add in case of comment line. - execute-keys -draft k ^\h*-- + execute-keys -draft kx ^\h*-- execute-keys -draft oxendgenerate ] ] # Wisely add "end case;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(case|.*\h*:\h*case)\b }i ^x(?i)end + execute-keys -draft kx ^\h*(?i)(case|.*\h*:\h*case)\b }ix ^x(?i)end execute-keys -draft oxendcase ] ] # Wisely add "begin" and "end block;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)((block|.*:\h*block)\b) }i ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i)((block|.*:\h*block)\b) }ix ^x(?i)(begin|end) execute-keys -draft oxbeginxendblock ] ] # Wisely add "begin" and "end process;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b }i ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b }ix ^x(?i)(begin|end) execute-keys -draft oxbeginxendprocess ] ] # Wisely add "end loop;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ }i ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ }ix ^x(?i)(end) execute-keys -draft oxendloop ] ] # Wisely add "end protected;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+protected)$ }i ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+protected)$ }ix ^x(?i)(end) execute-keys -draft oxendprotected ] ] # Wisely add "end protected body;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(\h*type\h+\w+\h+is\h+protected\h+body$) }i ^x(?i)end\h+protected\h+body\b + execute-keys -draft kx ^(?i)(\h*type\h+\w+\h+is\h+protected\h+body$) }ix ^x(?i)end\h+protected\h+body\b execute-keys -draft oxendprotectedbody ] ] # Wisely add "end record;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+record\h*)$ }i ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+record\h*)$ }ix ^x(?i)(end) execute-keys -draft oxendrecord ] ] # Wisely add ");" for "type ... is (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+\(\h*)$ }i ^x(\)) + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+\(\h*)$ }ix ^x(\)) execute-keys -draft ox) ] ] # Wisely add "end entity;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)\h*entity\b.*\bis$ }i ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)\h*entity\b.*\bis$ }ix ^x(?i)(begin|end) execute-keys -draft oxendentity ] ] # Wisely add "begin" and "end function;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(\h*\)?\h*return\b.*\bis$) }i ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)(\h*\)?\h*return\b.*\bis$) }ix ^x(?i)(begin|end) execute-keys -draft oxbeginxendfunction ] try %[ - execute-keys -draft k ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) }i ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) }ix ^x(?i)(begin|end) execute-keys -draft oxbeginxendfunction ] ] # Wisely add "begin" and "end procedure;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(\h*procedure\b.*\bis$) }i ^x(?i)\b(begin|end)\b + execute-keys -draft kx ^(?i)(\h*procedure\b.*\bis$) }ix ^x(?i)\b(begin|end)\b execute-keys -draft oxbeginxendprocedure ] try %[ - execute-keys -draft k ^(?i)\h*\)\h*\bis$ }i ^x(?i)\b(begin|end)\b + execute-keys -draft kx ^(?i)\h*\)\h*\bis$ }ix ^x(?i)\b(begin|end)\b # Verify that line with opening parenthesis contains "procedure" keyword. - execute-keys -draft k s\) (?i)\bprocedure\b + execute-keys -draft kx s\) x (?i)\bprocedure\b execute-keys -draft oxbeginxendprocedure ] ] # Wisely add "end package;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(package\b) }i ^x(?i)(end) + execute-keys -draft kx ^(?i)(package\b) }ix ^x(?i)(end) # Make sure it is not package body. - execute-keys -draft k(?i)\bbody\b + execute-keys -draft kx(?i)\bbody\b execute-keys -draft oendpackage ] ] # Wisely add "end package body;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(package\h+body\b) }i ^x(?i)(end) + execute-keys -draft kx ^(?i)(package\h+body\b) }ix ^x(?i)(end) execute-keys -draft oendpackagebody ] ] # Wisely add "begin" and "end architecture;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)\h*architecture\b }i ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)\h*architecture\b }ix ^x(?i)(begin|end) execute-keys -draft oxbeginxendarchitecture ] ] # Wisely add ");" for "port (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)port\h*\($ }i ^x(\)\;) + execute-keys -draft kx ^\h*(?i)port\h*\($ }ix ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "port map (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)port\h+map\h*\($ }i ^x(\)\;) + execute-keys -draft kx ^\h*(?i)port\h+map\h*\($ }ix ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "generic (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)generic\h*\($ }i ^x(\)\;) + execute-keys -draft kx ^\h*(?i)generic\h*\($ }ix ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ")" for "generic map (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)generic\h+map\h*\($ }i ^x(\)) + execute-keys -draft kx ^\h*(?i)generic\h+map\h*\($ }ix ^x(\)) execute-keys -draft ox) ] ] # Wisely add ") return ;" for "[pure|impure] function ... (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ }i ^x(\)\h*return.*) + execute-keys -draft kx ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ }ix ^x(\)\h*return.*) execute-keys -draft ox)return ] ] # Wisely add ");" for "procedure ... (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)procedure\b.*\h*\($ }i ^x(\)\h*\;) + execute-keys -draft kx ^\h*(?i)procedure\b.*\h*\($ }ix ^x(\)\h*\;) execute-keys -draft ox) ] ] @@ -357,9 +357,9 @@ define-command -hidden vhdl-indent-on-new-line %{ # Align "then" to previous "if|elsif". evaluate-commands -itersel -save-regs x %[ try %[ - execute-keys -draft k (?i)^\h*then$ - try %[ execute-keys -draft (?i)\b(if|elsif)\bs^\h+"xy ] catch %[ reg x '' ] - try %[ execute-keys -draft k s^\h+d ] catch %[ ] + execute-keys -draft k x (?i)^\h*then$ + try %[ execute-keys -draft (?i)\b(if|elsif)\bxs^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft k xs^\h+d ] catch %[ ] execute-keys -draft kgh ix ] ] @@ -367,9 +367,9 @@ define-command -hidden vhdl-indent-on-new-line %{ # Align "generate" to previous "if|for". evaluate-commands -itersel -save-regs x %[ try %[ - execute-keys -draft k (?i)^\h*generate$ - try %[ execute-keys -draft (?i)\b(if|for)\bs^\h+"xy ] catch %[ reg x '' ] - try %[ execute-keys -draft k s^\h+d ] catch %[ ] + execute-keys -draft k x (?i)^\h*generate$ + try %[ execute-keys -draft (?i)\b(if|for)\bxs^\h+"xy ] catch %[ reg x '' ] + try %[ execute-keys -draft k xs^\h+d ] catch %[ ] execute-keys -draft kgh ix ] ] @@ -378,38 +378,38 @@ define-command -hidden vhdl-indent-on-new-line %{ try %[ execute-keys -draft K ] # Cleanup trailing whitespaces from previous line. - try %[ execute-keys -draft k s \h+$ d ] + try %[ execute-keys -draft k x s \h+$ d ] # Increase indent after some keywords. try %[ - execute-keys -draft k (?i)\b(begin|block|body|else|for|generate|if|is|loop|process|protected|record|select|then)$ + execute-keys -draft kx (?i)\b(begin|block|body|else|for|generate|if|is|loop|process|protected|record|select|then)$ # Does not indent if in comment line. - execute-keys -draft k(?i)^\h*-- + execute-keys -draft kx(?i)^\h*-- # Handle case line in a bit different way. - execute-keys -draft k(?i)^\h*case\b + execute-keys -draft kx(?i)^\h*case\b execute-keys -draft ] # Add "when " and increase indent after "case ... is". try %[ - execute-keys -draft k (?i)\h*case\b.*\h+is$ + execute-keys -draft kx (?i)\h*case\b.*\h+is$ # Don't indent if in comment line. - execute-keys -draft k(?i)^\h*-- + execute-keys -draft kx(?i)^\h*-- execute-keys -draft iwhen ] # Copy the indentation of the matching if. - try %{ execute-keys -draft k ^\h*(elsif\b|else$) gh [c^\h*(\S*\h*:\h*)?if\b,\bend\sif\b 1 j K } + try %{ execute-keys -draft k x ^\h*(elsif\b|else$) gh [c^\h*(\S*\h*:\h*)?if\b,\bend\sif\b x 1 j K } # Increase indent after some operators. - try %[ execute-keys -draft k (\(|=>|<=|:=)$ j ] + try %[ execute-keys -draft k x (\(|=>|<=|:=)$ j ] } } define-command vhdl-indent-on-closing-parenthesis %[ evaluate-commands -itersel %[ # Decrease indent after ")" at the beginning of line. - try %[ execute-keys -draft (^\h+\)$) ] + try %[ execute-keys -draft x (^\h+\)$) ] ] ] diff --git a/rc/filetype/yaml.kak b/rc/filetype/yaml.kak index 7abaf22a..6bc79a4e 100644 --- a/rc/filetype/yaml.kak +++ b/rc/filetype/yaml.kak @@ -47,13 +47,13 @@ add-highlighter shared/yaml/code/ regex ^\h*-?\h*(\S+): 1:attribute define-command -hidden yaml-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden yaml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } diff --git a/rc/filetype/zig.kak b/rc/filetype/zig.kak index 27ca2c5f..fe1df7ac 100644 --- a/rc/filetype/zig.kak +++ b/rc/filetype/zig.kak @@ -97,13 +97,13 @@ add-highlighter shared/zig/code/ regex "@(?:addWithOverflow|alignCast|alignOf|as define-command -hidden zig-trim-indent %{ # delete trailing whitespace - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden zig-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // or /// comments prefix or \\ string literal prefix and following whitespace - try %< execute-keys -draft k s ^\h*\K(///?|\\\\)\h* y gh j P > + try %< execute-keys -draft k x s ^\h*\K(///?|\\\\)\h* y gh j P > > > @@ -113,11 +113,11 @@ define-command -hidden zig-indent-on-new-line %< try %< execute-keys -draft K > try %< # only if we didn't copy a comment or multiline string - execute-keys -draft ^\h*(//|\\\\) + execute-keys -draft x ^\h*(//|\\\\) # indent after lines ending in { - try %< execute-keys -draft k \{\h*$ j > + try %< execute-keys -draft k x \{\h*$ j > # deindent closing } when after cursor - try %< execute-keys -draft ^\h*\} gh / \} m 1 > + try %< execute-keys -draft x ^\h*\} gh / \} m 1 > > # filter previous line try %< execute-keys -draft k : zig-trim-indent > diff --git a/rc/tools/autowrap.kak b/rc/tools/autowrap.kak index c900abc6..d742f6ee 100644 --- a/rc/tools/autowrap.kak +++ b/rc/tools/autowrap.kak @@ -13,7 +13,7 @@ declare-option -docstring %{ define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m' %{ try %{ ## if the line isn't too long, do nothing - execute-keys -draft "^[^\n]{%opt{autowrap_column},}[^\n]" + execute-keys -draft "x^[^\n]{%opt{autowrap_column},}[^\n]" try %{ reg m "%val{selections_desc}" @@ -30,7 +30,7 @@ define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m' | sed "s/%c/${kak_opt_autowrap_column}/g") printf %s " evaluate-commands -draft %{ - execute-keys 'p|${format_cmd}' + execute-keys 'px|${format_cmd}' try %{ execute-keys s\h+$ d } } select '${kak_main_reg_m}' diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index c7c27a35..dd86c0f0 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -43,7 +43,7 @@ declare-option -docstring "name of the client in which all source code jumps wil define-command -hidden grep-jump %{ evaluate-commands %{ # use evaluate-commands to ensure jumps are collapsed try %{ - execute-keys 's^((?:\w:)?[^:]+):(\d+):(\d+)?' + execute-keys 'xs^((?:\w:)?[^:]+):(\d+):(\d+)?' set-option buffer grep_current_line %val{cursor_line} evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing %reg{1} %reg{2} %reg{3} try %{ focus %opt{jumpclient} } diff --git a/src/main.cc b/src/main.cc index ab476458..f0088265 100644 --- a/src/main.cc +++ b/src/main.cc @@ -48,6 +48,7 @@ struct { "» pipe commands do not append final end-of-lines anymore\n" "» {+u}complete-command{} to configure command completion\n" "» {+b}!{} and {+b}{} now select the inserted text\n" + "» {+b}x{} now uses {+b}{} behaviour\n" }, { 20211107, "» colored and curly underlines support (undocumented in 20210828)\n" diff --git a/src/normal.cc b/src/normal.cc index 27bdb3dd..51027529 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -2294,10 +2294,8 @@ static constexpr HashMap { {alt('h')}, {"select to line begin", repeated>>} }, { {alt('H')}, {"extend to line begin", repeated>>} }, - { {'x'}, {"select line", repeated>} }, - { {'X'}, {"extend line", repeated>} }, - { {alt('x')}, {"extend selections to whole lines", select} }, - { {alt('X')}, {"crop selections to whole lines", select} }, + { {'x'}, {"extend selections to whole lines", select} }, + { {alt('x')}, {"crop selections to whole lines", select} }, { {'m'}, {"select to matching character", select>} }, { {alt('m')}, {"backward select to matching character", select>} }, diff --git a/src/selectors.cc b/src/selectors.cc index b0aa83b0..43819034 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -173,19 +173,6 @@ select_word(const Context& context, const Selection& selection, template Optional select_word(const Context&, const Selection&, int, ObjectFlags); template Optional select_word(const Context&, const Selection&, int, ObjectFlags); -Optional -select_line(const Context& context, const Selection& selection) -{ - auto& buffer = context.buffer(); - auto line = selection.cursor().line; - // Next line if line fully selected - if (selection.anchor() <= BufferCoord{line, 0_byte} and - selection.cursor() == BufferCoord{line, buffer[line].length() - 1} and - line != buffer.line_count() - 1) - ++line; - return Selection{{line, 0_byte}, {line, buffer[line].length() - 1, max_column}}; -} - template Optional select_to_line_end(const Context& context, const Selection& selection) diff --git a/test/indent/comment/comment-multiple-lines-indented/cmd b/test/indent/comment/comment-multiple-lines-indented/cmd index 2330d00f..ea76f7d3 100644 --- a/test/indent/comment/comment-multiple-lines-indented/cmd +++ b/test/indent/comment/comment-multiple-lines-indented/cmd @@ -1 +1 @@ -jXXXXX:comment-line +jGex:comment-line diff --git a/test/normal/extend-lines/cmd b/test/normal/extend-lines/cmd index 9e785e6d..587be6b4 100644 --- a/test/normal/extend-lines/cmd +++ b/test/normal/extend-lines/cmd @@ -1 +1 @@ - +x diff --git a/test/normal/select-line-extending/cmd b/test/normal/select-line-extending/cmd deleted file mode 100644 index 62d8fe9f..00000000 --- a/test/normal/select-line-extending/cmd +++ /dev/null @@ -1 +0,0 @@ -X diff --git a/test/normal/select-line-extending/in b/test/normal/select-line-extending/in deleted file mode 100644 index 257cc564..00000000 --- a/test/normal/select-line-extending/in +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/test/normal/select-line-extending/kak_quoted_selections b/test/normal/select-line-extending/kak_quoted_selections deleted file mode 100644 index 97a30d3c..00000000 --- a/test/normal/select-line-extending/kak_quoted_selections +++ /dev/null @@ -1,2 +0,0 @@ -'foo -' diff --git a/test/normal/trim-lines/cmd b/test/normal/trim-lines/cmd index d786ed97..9e785e6d 100644 --- a/test/normal/trim-lines/cmd +++ b/test/normal/trim-lines/cmd @@ -1 +1 @@ - +