# Using other name than keys name in \`execute-keys\`, \`map\`, etc

**URL:** <https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177>\
**Category:** Complaints & Improvements\
**Tags:** key, language\
**Created:** [July 30, 2020, 9:58am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177 "2020-07-30T09:58:24Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 30, 2020, 9:58am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/1 "2020-07-30T09:58:24Z")

</div>

Hello !

Anyone has remapped most of kakoune keybinding to a point where it’s difficult to write/read script using the `execute-keys` function ?

I feel like it would be more readable to have:

`execute-keys <unselect> <go_down> <find> ) <insert_after> : `  
than  
`execute-keys <space>jf)a:`  
Even more if you remapped `space` to `backspace`, `f` to `^` etc…

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [July 30, 2020, 6:51pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/2 "2020-07-30T18:51:21Z")

</div>

- [#2358](https://github.com/mawww/kakoune/issues/2358)

There is another issue I opened, but I don’t find it.

---

<div class="post-metadata">

**Author:** ![vbauerster](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vbauerster](https://discuss.kakoune.com/u/vbauerster)\
**Post date:** [July 31, 2020, 7:17am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/3 "2020-07-31T07:17:19Z")

</div>

I usually refer to [https://delapouite.github.io/kakoune-explain/keys.html](https://delapouite.github.io/kakoune-explain/keys.html) when forgetting something.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [July 31, 2020, 7:28am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/4 "2020-07-31T07:28:38Z")

</div>

Scripts would be more readable using names.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 8:59am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/5 "2020-07-31T08:59:04Z")

</div>

yeah but it’s a bit painfull to go see a ref. should be readable right away

---

<div class="post-metadata">

**Author:** ![vbauerster](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vbauerster](https://discuss.kakoune.com/u/vbauerster)\
**Post date:** [July 31, 2020, 9:00am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/6 "2020-07-31T09:00:32Z")

</div>

> [@alexherbo2](#):
>
> Scripts would be more readable using names.

I totally agree with you, just provided a link for reference.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 10:51am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/7 "2020-07-31T10:51:02Z")

</div>

In the issue you mention it’s about adding a help tool with clippy, which could be nice but its not really my point: I don’t understand the design choice of using the shortcut key for the function name instead of a explicit function name.

I think it would make much more sense to directly use proper function name: it improve readability and doesn’t punish people who remap default kakoune keybinding.

---

<div class="post-metadata">

**Author:** ![tototest99](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/tototest99/32/629_2.png) [@tototest99](https://discuss.kakoune.com/u/tototest99)\
**Post date:** [July 31, 2020, 11:11am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/8 "2020-07-31T11:11:22Z")

</div>

You can use `with-maps` option of `execute-keys` to take into account your remaps, and format a bit the sequence of keys in %{…} delimiters for readability.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 11:19am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/9 "2020-07-31T11:19:53Z")

</div>

hmm yeah but then if I edit my remap in the future it can break my scripts. So proper function name are more stable

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [July 31, 2020, 11:58am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/10 "2020-07-31T11:58:16Z")

</div>

For better or for worse, Kakoune is a very punk-rock editor. It’s very much about letting users build things for themselves, rather than giving people a unified and harmonious Text Editing Environment. It is, if you will, the anti-Emacs. For example, Kakoune’s extension language is POSIX shell. Not because it’s an especially beautiful language, or simple, or powerful, but because it makes it easy to integrate with other tools people use, and because people already know it.

In the same way, Kakoune’s `execute-keys` feature uses ordinary normal-mode key mappings instead of human-readable names like “collapse-selections-to-cursor” or “previous-line”. Not because it’s especially beautiful or readable, but because people (who haven’t remapped all the keys) already know it.

It is really, really easy to write your first shell-script to automate a repetitive task: take all the commands you ran interactively, copy them out of your terminal’s scrollback, paste them into a text file, and make the text file executable.

It is very nearly as easy to write your first Kakoune command to automate a repetitive task: you have to add some `define-command` boiler-plate, and you might need learn the names of special keys like `<lt>` and `<semicolon>`, but mostly you can just type the same keys you would type to do the thing interactively.

I have been a professional programmer; I’m prepared to bring up a diagram showing the inheritance hierarchy of nodes in the document model and an API reference listing the methods available on each node, if I have to. But there’s something refreshing about writing `:execute-keys <space>jf)a:<esc>` and _knowing_ there’s no additional scope for yak-shaving, so I can get on with whatever I was trying to do.

---

<div class="post-metadata">

**Author:** ![ftonneau](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ftonneau/32/295_2.png) [@ftonneau](https://discuss.kakoune.com/u/ftonneau)\
**Post date:** [July 31, 2020, 12:32pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/11 "2020-07-31T12:32:49Z")

</div>

I can’t find anymore where I read it (somewhere in the docs), but `execute-keys` concatenates its arguments, so keys can be grouped, and the groups space-separated, without any need for bracket delimiters. For example:

```
execute-keys <space> j f) a:

```

will work as well as:

```
execute-keys <space>jf)a:

```

I think this increases legibility, especially when dealing with complicated regexes.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 1:05pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/12 "2020-07-31T13:05:29Z")

</div>

‘Punk-rock’ is a beautiful way to describe kakoune, and this is why I love it too.

But for me remapping default keybinding to my needs also follow the same DIY editor philosophy. ( edit: just looking at this forum, the github etc… I feel that that remapping is already a big part of kakoune, even the “official” wiki suggest remapping `space` to enter user-mode )

In my opinion it’s not very punk rock to say “this is the ultimate keybinding for every user and every use case, therefore we use normal-mode key mapping as the function’s name” 😛 .

> [@Screwtapello](#):
>
> It is really, really easy to write your first shell-script to automate a repetitive task: take all the commands you ran interactively, copy them out of your terminal’s scrollback, paste them into a text file, and make the text file executable.

I agree that it’s very easy to write your first repetitive task with kakoune, _assuming one havn’t remapped default keybinding_.

But I don’t think using proper function name would make it harder for two reasons:

1. You could have `execute-keys` and `execute-fn` living together. `execute-keys` would act like `execute-keys -with-maps` that is perfect for quick automation, and `execute-fn` that use proper function name which is better for more complex, sharable and readable code ( inside a pluggin for example ).

2. Also I can imaging a function `key-to-fn` that would transform key to function name.  
For example if I select  
`jf)a:`  
and run the command `:key-to-fn<ret>` then the selection would be transformed to

```auto
<go_down> <find> ) <insert_after> : 

```

Solution 1 and 2 are not incompatible.

Last point: IMO it make more sense and be more easy to transform customed keybind into a function using he above `key-to-fn` than to use a helper like [#2358](https://github.com/mawww/kakoune/issues/2358) or refer to [Kakoune keys](https://delapouite.github.io/kakoune-explain/keys.html) every time you want to make an automation.

---

<div class="post-metadata">

**Author:** ![tototest99](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/tototest99/32/629_2.png) [@tototest99](https://discuss.kakoune.com/u/tototest99)\
**Post date:** [July 31, 2020, 2:13pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/13 "2020-07-31T14:13:01Z")

</div>

Sorry, I may be thinking a bit too loud here:

- I wonder what the added complexity that would be needed to the codebase just for that…
- Unless I’m mistaken it goes against the original design: [github.com/mawww/kakoune/blob/master/doc/design.asciidoc#unified-interactive-use-and-scripting](http://github.com/mawww/kakoune/blob/master/doc/design.asciidoc#unified-interactive-use-and-scripting), and with threads like “kakoune-needs-a-real-scripting-language”, I begin to smell the history of Vimscript (ex, execute, variable and control flow)… which triggers me (PTSD, sorry) toward this kind of reaction [The Inner Platform Effect](https://discuss.kakoune.com/t/the-inner-platform-effect/1113).
- So that you have minimal `execute-keys` and `evaluate-commands` and `hooks` to deal with ,and/or when doing logic with `sh` become cumbersome, IMVHO IPC solidification to access the partial states of Kakoune like selections, registers, etc., and just enough abstraction like unification of registers-options-hooks, are inspiring.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 5:33pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/14 "2020-07-31T17:33:32Z")

</div>

> [@tototest99](#):
>
> I wonder what the added complexity that would be needed to the codebase just for that…

I guess not much, I beleive you just need to change the parser to parse `<delete>` instead of `d`. Actually it might even make codebase more simple, since it’s more easy to parse `<delete>` than `d` ( `d` is ambigious, it could be a `d` from insert mode )

> [@tototest99](#):
>
> Unless I’m mistaken it goes against the original design: [github.com/mawww/kakoune/blob/master/doc/design.asciidoc#unified-interactive-use-and-scripting](http://github.com/mawww/kakoune/blob/master/doc/design.asciidoc#unified-interactive-use-and-scripting),

It does goes again the original design, but I think this original idea can be criticize. Think of people using non qwerty keyboard that need to remap the “hjkl;:” , it makes kakoun script hard to read/write .

> and with threads like “kakoune-needs-a-real-scripting-language”, I begin to smell the history of Vimscript (ex, execute, variable and control flow)… which triggers me (PTSD, sorry) toward this kind of reaction [The Inner Platform Effect](https://discuss.kakoune.com/t/the-inner-platform-effect/1113).

I hate Vimscript too and I’m also against kakoune going this direction. But this is not about creating a scripting language for kakoune. It’s about **using another naming convention for stuff that already exist** : using full words instead of letter ( `<delete>` instead of `d`).

So inner platform effect at all ! No added complexity either, just a different naming convention.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [July 31, 2020, 5:45pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/15 "2020-07-31T17:45:53Z")

</div>

> [@Kakoune needs a real scripting language](https://discuss.kakoune.com/t/kakoune-needs-a-real-scripting-language/575/10):
>
> I have been for a long time on the fence about a suggestion by @alexherbo2: have alternate names for normal mode keys, such as `<keep-matching>` , `<split-on-regex>` , `<align>` …
> 
> I think this would go a long way into making normal mode scripts much easier to understand, but would unfortunately decorelate the interactive keystroke from the scripting command name (although using the key directly should still work, the idea would not be to introduce an indirection from `a` to `<append>` , they are the same key.
> 
> As said initially, I am not sold on this, but maybe it would be a good direction to explore.

Found this… Didnt understood the "would unfortunately decorelate the interactive keystroke from the scripting command name " but I agreed on “a good direction to explore”

---

<div class="post-metadata">

**Author:** ![tototest99](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/tototest99/32/629_2.png) [@tototest99](https://discuss.kakoune.com/u/tototest99)\
**Post date:** [July 31, 2020, 9:22pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/16 "2020-07-31T21:22:12Z")

</div>

just half-assed musing:  
In `lexicon.kak`:

```auto
declare-option str sub_select s
declare-option str last_spaces \h+$
declare-option str delete d
declare-option str select_current_line x

```

in `kakrc`:

```auto
source lexicon.kak

```

then trim space at end of line:  
`eval %{exec %opt<select_current_line> %opt<sub_select> %opt<last_spaces> <ret> %opt<delete>}`  
obviously should be used for more complicated atoms…

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [July 31, 2020, 9:50pm UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/17 "2020-07-31T21:50:41Z")

</div>

> [@scr](#):
>
> Think of people using non qwerty keyboard that need to remap the “hjkl;:” , it makes kakoun script hard to read/write .

This is indeed a good point.

---

<div class="post-metadata">

**Author:** ![terids](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/terids/32/1575_2.png) [@terids](https://discuss.kakoune.com/u/terids)\
**Post date:** [September 17, 2025, 4:09am UTC](https://discuss.kakoune.com/t/using-other-name-than-keys-name-in-execute-keys-map-etc/1177/18 "2025-09-17T04:09:36Z")

</div>

I’m a bit late to the party, but had a similar issue and decided to make a plugin that maps all of the default keybinds to options.  
[https://codeberg.org/terids/kak-keyoptions](https://codeberg.org/terids/kak-keyoptions)

I also went ahead and created a separate plugin to map them to commands as well, but bear in mind that commands won’t work with count prefixes if using them for remaps, the options plugin works great for that.  
[https://codeberg.org/terids/kak-keycommands](https://codeberg.org/terids/kak-keycommands)
