kakoune plugin providing extra text-objects
Add text-objects.kak
to your autoload dir: ~/.config/kak/autoload/
.
Or via plug.kak:
plug 'delapouite/kakoune-text-objects' %{
text-object-map
}
How many modes are there in Kakoune? 8?
normal
, insert
, menu
, prompt
, goto
, view
, object
and user
?
Unfortunately on-key modes like object
are in fact divided in sub-modes:
<a-i>q
, <a-a>q
or [q
(to name only a few of the possibilities) all
offer a slightly different behavior.
The problem occurs when you declare a new mapping like:
map global object f foo
There's currently no native way to differentiate between an object triggered by
<a-i>f
or <a-a>f
.
This plugin attempts to address this issue.
This plugin enhances the pairs text-objects ((
, )
, {
, }
…).
Let's illustrate with the braces
text-object.
If the cursor is in a C function simple body and press <a-i>{
it will select it.
But what if the cursor is in the main scope, just few lines below the function?
Normally, the <a-i>{
would result in a noop and nothing would be selected.
With the enhanced behavior provided <a-i>{
will attempt to find the previous
{…}
in the code and select the inside of it. <a-a>{
would do the same but select
the braces as well. With <a-i>}
it will search the next couple.
See mawww/kakoune#9
By default Kakoune does not provide a real line text-object. This line concept is
scattered around different keys like x
, <a-h>
, <a-l>
, Gh
, Gi
…
This plugins tries to reunite them under the x
text-object.
For example <a-a>x
selects the whole line (EOL included), while <a-i>x
, only select
inside the line (not leading spaces and EOL excluded).
You may find this text-object redundant or even useless, but I found it nice to reinforce Kakoune's orthogonality.
By default Kakoune does not provide a real buffer text-object. This buffer concept is
scattered around different keys like %
, Gj
, Gk
, Ge
…
This plugins tries to reunite them under the f
text-object.
For example <a-a>f
selects the whole buffer, while <a-i>f
, only select
inside the buffer (not leading or trailing spaces).
You may find this text-object redundant or even useless, but I found it nice to reinforce Kakoune's orthogonality.
Depends on kakoune-vertical-selection.
It's a great companion to the builtin C
key. <a-i>v
selects up and down, [v
selects up
and ]v
selects down.
There's currently a t
text-object but it's very much work in progress at this stage.
Use it with caution.
A selectors
user-mode is provided. Use the text-object-map
command to enable it.
By default it is mapped on user s
. Its goal is to avoid using the alt
key as much as possible
and the related acrobatic fingers chords over the keyboard.
Example: to extend the selections until the next bracket.
From <a-}> ]
to , s K ]
You are guided by auto-info boxes along the way.
Thanks a lot to occivink and alex for inspiration.
MIT