# \#scripting

**URL:** https://discuss.kakoune.com/tag/scripting/43.md

[Latest](https://discuss.kakoune.com/latest.md) · [Categories](https://discuss.kakoune.com/categories.md) · [Tags](https://discuss.kakoune.com/tags.md)

---

## [Selecting whole buffer immediately after a grep command](https://discuss.kakoune.com/t/selecting-whole-buffer-immediately-after-a-grep-command/2750)

<div class="topic-metadata">

**Author:** [@albak](https://discuss.kakoune.com/u/albak)\
**Replies:** 2\
**Last updated:** [September 4, 2025, 10:21pm UTC](https://discuss.kakoune.com/t/selecting-whole-buffer-immediately-after-a-grep-command/2750 "2025-09-04T22:21:53Z")

</div>

Hello fellow mouilleurs I’m trying to create a command that greps a pattern in a buffer, selects the whole grep buffer and applies a few commands (aligns the matched patterns). I am getting an error/inconsistency. My c…

---

## [Simplifying snippets (if possible)?](https://discuss.kakoune.com/t/simplifying-snippets-if-possible/2526)

<div class="topic-metadata">

**Author:** [@The-BigDaddy](https://discuss.kakoune.com/u/The-BigDaddy)\
**Replies:** 1\
**Last updated:** [August 15, 2024, 3:53pm UTC](https://discuss.kakoune.com/t/simplifying-snippets-if-possible/2526 "2024-08-15T15:53:05Z")

</div>

Hey gang, So I know kakoune-snippets has been the go-to snippet plugin for awhile, but I was wondering if there’s another way of doing snippets. Let’s me go through my thought process: We have a folder called snippets …

---

## [Kakscript: boolean / string / error equality testing](https://discuss.kakoune.com/t/kakscript-boolean-string-error-equality-testing/1959)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 4\
**Last updated:** [December 24, 2021, 1:35pm UTC](https://discuss.kakoune.com/t/kakscript-boolean-string-error-equality-testing/1959 "2021-12-24T13:35:01Z")

</div>

Here’s a way to check boolean, string and error equality in pure kakscript. These techniques are used, for example, in my Forth implementation in pure kakscript. Disclaimers def’s are prefixed with mypkg- (sometimes im…

---

## [Eine kleine Forth machine](https://discuss.kakoune.com/t/eine-kleine-forth-machine/1957)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 0\
**Last updated:** [December 12, 2021, 4:36pm UTC](https://discuss.kakoune.com/t/eine-kleine-forth-machine/1957 "2021-12-12T16:36:02Z")

</div>

I’ve written an (incomplete) Forth interpreter on top of kakscript. This was a rather complex effort, which still needs more documenting, and I would like some feedback as time permits (@mawww ?). To use, clone and sy…

---

## [\`decl\` with value vs \`set\`; \`update-option\`](https://discuss.kakoune.com/t/decl-with-value-vs-set-update-option/1921)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 6\
**Last updated:** [November 11, 2021, 3:55am UTC](https://discuss.kakoune.com/t/decl-with-value-vs-set-update-option/1921 "2021-11-11T03:55:39Z")

</div>

It seems that using decl int int\_opt VALUE can be used anywhere in code, at any point during runtime (not just at load-time); it seems to be the same as set global, without needing to pre-declare the option. Are there an…

---

## [Filetype hilight hooks](https://discuss.kakoune.com/t/filetype-hilight-hooks/1894)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 1\
**Last updated:** [September 25, 2021, 8:47am UTC](https://discuss.kakoune.com/t/filetype-hilight-hooks/1894 "2021-09-25T08:47:31Z")

</div>

Like all good plugin writers (who define highlighters) I’ve copied over (and of course adapted) this, from grep.kak hook -once -always window WinSetOption filetype=.\* %{ remove-highlighter window/grep } What is the pur…

---

## [Kakscript has loop, catch this, head/tail/shift, int\>=0, streq ... etc](https://discuss.kakoune.com/t/kakscript-has-loop-catch-this-head-tail-shift-int-0-streq-etc/1885)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 0\
**Last updated:** [September 21, 2021, 4:56am UTC](https://discuss.kakoune.com/t/kakscript-has-loop-catch-this-head-tail-shift-int-0-streq-etc/1885 "2021-09-21T04:56:13Z")

</div>

Note: (entire demo downloadable in one script). Friends, let’s talk about scripting in kakscript, not other languages. Unexpectedly, a lot of things are possible — a lot more than you might think at first. I’ve been usi…

---

## [Sel-editor: editable, live selection-summary buffer](https://discuss.kakoune.com/t/sel-editor-editable-live-selection-summary-buffer/1877)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 3\
**Last updated:** [September 16, 2021, 9:08pm UTC](https://discuss.kakoune.com/t/sel-editor-editable-live-selection-summary-buffer/1877 "2021-09-16T21:08:39Z")

</div>

This plugin, suggested by @Guest0 and @Screwtapello , renders a summary of the current window’s multiple selections (ranges + contents) in a \*selections\* buffer. It can act as a toolsclient, and live-update \*selection…

---

## [Enable hook only for specific client](https://discuss.kakoune.com/t/enable-hook-only-for-specific-client/1880)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 1\
**Last updated:** [September 14, 2021, 9:51pm UTC](https://discuss.kakoune.com/t/enable-hook-only-for-specific-client/1880 "2021-09-14T21:51:31Z")

</div>

How can I enable a NormalIdle hook only for the current client? For example in my sel-editor, when enabling live-updating for the \*selections\* summary buffer, I want a NormalHook that applies only to the client that call…

---

## [Scripting Kakoune with external tools](https://discuss.kakoune.com/t/scripting-kakoune-with-external-tools/1779)

<div class="topic-metadata">

**Author:** [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Replies:** 19\
**Last updated:** [September 12, 2021, 3:32am UTC](https://discuss.kakoune.com/t/scripting-kakoune-with-external-tools/1779 "2021-09-12T03:32:16Z")

</div>

I love the way Kakoune integrates with other scripting languages instead of requiring a particular language, but choosing which language to use requires some thought. POSIX shell Plugins can assume this is present, sinc…

---

## [Profiling \`sh\` invocations with \`fakesh\`](https://discuss.kakoune.com/t/profiling-sh-invocations-with-fakesh/1806)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 1\
**Last updated:** [August 4, 2021, 10:28pm UTC](https://discuss.kakoune.com/t/profiling-sh-invocations-with-fakesh/1806 "2021-08-04T22:28:16Z")

</div>

I’ve updated f8ksh (previous announcement) to enable invocation logging and counting (in addition to parsing shebang lines in commands — %sh{#! perl} …). Basically, F8KSH\_FAKESH\_COUNT=true \[F8KSH\_FAKESH\_DEBUG=true F8KSH…

---

## [\`#!\` shebangs in \`%sh\`](https://discuss.kakoune.com/t/shebangs-in-sh/1800)

<div class="topic-metadata">

**Author:** [@almr](https://discuss.kakoune.com/u/almr)\
**Replies:** 0\
**Last updated:** [June 29, 2021, 4:02pm UTC](https://discuss.kakoune.com/t/shebangs-in-sh/1800 "2021-06-29T16:02:41Z")

</div>

I have this in my kakrc: def tst -params .. %{ echo -debug %sh{#!perl -wn print if /:root:/ } } tst /etc/passwd which produces the expected line in \*debug\* How? get fakesh.sh from f8ksh on GitLab run kak with…

---

## [Silently add a new buffer to a kakoune session](https://discuss.kakoune.com/t/silently-add-a-new-buffer-to-a-kakoune-session/1792)

<div class="topic-metadata">

**Author:** [@scr](https://discuss.kakoune.com/u/scr)\
**Replies:** 1\
**Last updated:** [June 23, 2021, 12:34pm UTC](https://discuss.kakoune.com/t/silently-add-a-new-buffer-to-a-kakoune-session/1792 "2021-06-23T12:34:46Z")

</div>

Is there a way form an external script to seemlessly and silently add a new buffer to an existing kakoune session ? For now I use kcr to run an :edit and :exec ga but it create an anoying glitch
