- Notifications
You must be signed in to change notification settings - Fork750
Eval Exec
Bruno Heridet edited this pageSep 28, 2017 ·1 revision
eval
/exec
commands are very powerful construct. They support many switches that may be hard to understand at first.This page attempts to clarify their usage.
run once for each selection with that selection at the only one
Let's start by a simple buffer content:
foobarqux
and make 3 selections with:wCC
. The main selection is therefore onqux
.
def no-loop %{ eval %{ echo -debug %val{selection} echo -debug %val{selections} }}
If we run the aboveno-loop
command, here's the output of the `debug buffer:
quxfoo:bar:qux
Now, let's add the-itersel
switch:
def loop %{ eval -itersel %{ echo -debug %val{selection} echo -debug %val{selections} }}
This time, if we run thisloop
command, here's the debug output:
foofoobarbarquxqux
A few things to observe:
- the iteration starts from
foo
despite the fact thatqux
is our main selection. If the main selection wasbar
(by rotating with the'
command), the result would be the same. - as stated in the description of the
itersel
switch, in eachloop,%val{selection}
==%val{selections}
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV