~raiguard/kak-move-lines

cbfe4098cefb4746e32b6f99036091bb9ae00c5c — Caleb Heuer 4 months ago
Initial commit
3 files changed, 54 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A move-lines.kak
A  => LICENSE +19 -0
@@ 1,19 @@
Copyright © 2022 Caleb Heuer <ch@raiguard.me>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => README.md +22 -0
@@ 1,22 @@
# kak-move-lines

A plugin for the [kakoune](https://kakoune.org) text editor that allows you to
easily move your selected lines up and down.

## Installation

Source `move-lines.kak` in your `kakrc`, or use a plugin manager.

## Usage

The plugin provides the `move-lines-up` and `move-lines-down` commands. Intended
use is to bind these commands to keys in normal mode:

```
map global normal <c-s-j> ': move-lines-down %val{count}<ret>'
map global normal <c-s-k> ': move-lines-up %val{count}<ret>'
```

Note the use of single quotes and `%val{count}`. This allows you to optionally
specify the number of lines to move by - `<c-s-j>` will move down one line, but
`15<c-s-j>` will move down 15 lines.

A  => move-lines.kak +13 -0
@@ 1,13 @@
define-command move-lines-down \
-docstring 'move-lines-down [<count>] move selected lines down by <count> or one line' \
-params ..1 \
%{
    execute-keys -draft "x<a-_><a-:>Z;ez;%arg{1}J<a-;>LxdzP"
}

define-command move-lines-up \
-docstring 'move-lines-up [<count>] move selected lines up by <count> or one line' \
-params ..1 \
%{
    execute-keys -draft "x<a-_><a-:><a-;>Z;bz;%arg{1}K<a-;>Hxdzp"
}