Eval Exec - mawww/kakoune GitHub Wiki
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.
-itersel
run once for each selection with that selection at the only one
Let's start by a simple buffer content:
foo
bar
qux
and make 3 selections with: wCC
. The main selection is therefore on qux
.
def no-loop %{
eval %{
echo -debug %val{selection}
echo -debug %val{selections}
}
}
If we run the above no-loop
command, here's the output of the `debug buffer:
qux
foo: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 this loop
command, here's the debug output:
foo
foo
bar
bar
qux
qux
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 each loop,%val{selection}
==%val{selections}