diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-03-17 09:20:07 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-07-05 08:43:40 +1000 |
| commit | ef8a11b3dbefb8a1222974a8c34e15fa006d56e0 (patch) | |
| tree | e66d71d0a5d67c6bc43d4d5977b8468d0335b62d /rc/filetype/sh.kak | |
| parent | 046be3b06ce41922e363c742ee9470f0ac885d4b (diff) | |
Make `x` just select the full lines
`x` is often criticized as hard to predict due to its slightly complex
behaviour of selecting next line if the current one is fully selected.
Change `x` to use the previous `<a-x>` behaviour, and change `<a-x>` to
trim to fully selected lines as `<a-X>` did.
Adapt existing indentation script to the new behaviour
Diffstat (limited to 'rc/filetype/sh.kak')
| -rw-r--r-- | rc/filetype/sh.kak | 28 |
1 files changed, 14 insertions, 14 deletions
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 (?<!\\)(?:\\\\)*\K\$(\w+ define-command -hidden sh-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d } + try %{ execute-keys -draft -itersel x s \h+$ <ret> 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 <a-x> s ^\h*\K#\h* <ret> y gh j P } + try %{ execute-keys -draft k x s ^\h*\K#\h* <ret> y gh j P } ] ] @@ -120,11 +120,11 @@ define-command -hidden sh-indent-on-new-line %¶ # done # # indent after do - try %{ execute-keys -draft <space> k <a-x> <a-k> \bdo$ <ret> j <a-gt> } + try %{ execute-keys -draft <space> k x <a-k> \bdo$ <ret> j <a-gt> } # 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 <space> k <a-x> <a-k> \bdone$ <ret> gh [c\bdo\b,\bdone\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> } + try %{ execute-keys -draft <space> k x <a-k> \bdone$ <ret> gh [c\bdo\b,\bdone\b <ret> x <a-S> 1<a-&> <space> j K <a-&> } # 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 <space> k <a-x> <a-k> \bthen$ <ret> j <a-gt> } + try %{ execute-keys -draft <space> k x <a-k> \bthen$ <ret> j <a-gt> } # copy the indentation of the matching if - try %{ execute-keys -draft <space> k <a-x> <a-k> \bfi$ <ret> gh [c\bif\b,\bfi\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> } + try %{ execute-keys -draft <space> k x <a-k> \bfi$ <ret> gh [c\bif\b,\bfi\b <ret> x <a-S> 1<a-&> <space> j K <a-&> } # copy the indentation of the matching if, and then re-indent afterwards - try %{ execute-keys -draft <space> k <a-x> <a-k> \belse$ <ret> gh [c\bif\b,\bfi\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> j <a-gt> } + try %{ execute-keys -draft <space> k x <a-k> \belse$ <ret> gh [c\bif\b,\bfi\b <ret> x <a-S> 1<a-&> <space> j K <a-&> j <a-gt> } # 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 <space> k <a-x> <a-k> \bin$ <ret> j <a-gt> } + try %{ execute-keys -draft <space> k x <a-k> \bin$ <ret> j <a-gt> } # copy the indentation of the matching case - try %{ execute-keys -draft <space> k <a-x> <a-k> \besac$ <ret> gh [c\bcase\b,\besac\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> } + try %{ execute-keys -draft <space> k x <a-k> \besac$ <ret> gh [c\bcase\b,\besac\b <ret> x <a-S> 1<a-&> <space> j K <a-&> } # indent after ) - try %{ execute-keys -draft <space> k <a-x> <a-k> ^\s*\(?[^(]+[^)]\)$ <ret> j <a-gt> } + try %{ execute-keys -draft <space> k x <a-k> ^\s*\(?[^(]+[^)]\)$ <ret> j <a-gt> } # deindent after ;; - try %{ execute-keys -draft <space> k <a-x> <a-k> ^\s*\;\;$ <ret> j <a-lt> } + try %{ execute-keys -draft <space> k x <a-k> ^\s*\;\;$ <ret> j <a-lt> } # 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 <space> k <a-x> <a-k> (\s|^)\{$ <ret> j <a-gt> = + try %= execute-keys -draft <space> k x <a-k> (\s|^)\{$ <ret> j <a-gt> = # deindent closing } - try %= execute-keys -draft <space> k <a-x> <a-k> ^\s*\}$ <ret> <a-lt> j K <a-&> = + try %= execute-keys -draft <space> k x <a-k> ^\s*\}$ <ret> <a-lt> j K <a-&> = # deindent closing } when after cursor - try %= execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> = + try %= execute-keys -draft x <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> = @ ¶ |
