Repository navigation
Selections
map global user a '*%s' -docstring 'select all'
def -params 1 extend-line-down %{
exec "%arg{1}X"
}
def -params 1 extend-line-up %{
exec "%arg{1}K"
try %{
exec -draft ';\n'
exec X
}
exec ''
}
map global normal x ':extend-line-down %val{count}'
map global normal X ':extend-line-up %val{count}'
Also checkout the vertical-selection plugin
so when you want to select the word - you select it like textobject, more here
def -hidden select-prev-word-part %{
exec [A-Z][a-z]+|[A-Z]+|[a-z]+
}
def -hidden select-next-word-part %{
exec /[A-Z][a-z]+|[A-Z]+|[a-z]+
}
def -hidden extend-prev-word-part %{
exec [A-Z][a-z]+|[A-Z]+|[a-z]+
}
def -hidden extend-next-word-part %{
exec ?[A-Z][a-z]+|[A-Z]+|[a-z]+
}
map global normal w :select-next-word-part
map global normal W :extend-next-word-part
# foo_bar → fooBar
# foo-bar → fooBar
# foo bar → fooBar
def camelcase %{
exec '`s[-_]d~w'
}
# fooBar → foo_bar
# foo-bar → foo_bar
# foo bar → foo_bar
def snakecase %{
exec 's-|[a-z][A-Z];as[-\s]+c_w`'
}
# fooBar → foo-bar
# foo_bar → foo-bar
# foo bar → foo-bar
def kebabcase %{
exec 's_|[a-z][A-Z];as[_\s]+c-w`'
}
First solution using the keep regex primitive :
Second solution using the $ primitive.
In this particular case it's longer to type but it's more generic and powerful since you can construct predicates based on any value:
$[ ${#kak_selection} -gt 10 ]
Here we use a combination of the shell test command [ and the # operator in the var expansion.
Pipe your selection into sort: |sort
You can also deduplicate with the uniq command or reverse the letters of a word with rev using similar strategies.
def selection-hull %{
eval -save-regs 'abc' %{
exec '"aZ' '"bZ' '"az"cZ'
eval -itersel %{ exec '"bu' }
exec '"bz'
}
}
To go from
foo
bar
qux
to
1foo
2bar
3qux
Make one selection per line (with for instance), enter insert mode with I to move cursors at the beginning of each line and insert the content of the index register with .
- vertical-selection copy the current selection up and downwards to all lines matching the current selection.
- phantom-selection interactively iterate over the current selections one by one.
- select-view select the visible part of a buffer.
- auto-percent enhance some primitives with bigger selections
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV
