# \#hook

**URL:** https://discuss.kakoune.com/tag/hook/29.md

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

---

## [Hook doesn't work in kakrc but does work in file](https://discuss.kakoune.com/t/hook-doesnt-work-in-kakrc-but-does-work-in-file/2459)

<div class="topic-metadata">

**Author:** [@vorboyvo](https://discuss.kakoune.com/u/vorboyvo)\
**Replies:** 3\
**Last updated:** [April 11, 2024, 1:29pm UTC](https://discuss.kakoune.com/t/hook-doesnt-work-in-kakrc-but-does-work-in-file/2459 "2024-04-11T13:29:16Z")

</div>

Hi - I’m trying to set up auto-compilation for LaTeX files. To this end, I want to add a hook to compile on write: hook global BufWritePost %val{buffile} %{ texlab-build } This does not work when I put it in my kakrc…

---

## [Does anyone like .\*-insert hooks inserting comments?](https://discuss.kakoune.com/t/does-anyone-like-insert-hooks-inserting-comments/2056)

<div class="topic-metadata">

**Author:** [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Replies:** 6\
**Last updated:** [May 3, 2022, 3:42am UTC](https://discuss.kakoune.com/t/does-anyone-like-insert-hooks-inserting-comments/2056 "2022-05-03T03:42:43Z")

</div>

These hooks typically copy any comment prefix from a previous line. More often than not, I don’t want to copy comment prefixes. One workaround is to press \<ret\> twice but I found that hard to get used to that, plus it b…

---

## [Keyboard layout changing hook](https://discuss.kakoune.com/t/keyboard-layout-changing-hook/2041)

<div class="topic-metadata">

**Author:** [@Vlad\_Bojkiv](https://discuss.kakoune.com/u/Vlad_Bojkiv)\
**Replies:** 3\
**Last updated:** [April 12, 2022, 5:08am UTC](https://discuss.kakoune.com/t/keyboard-layout-changing-hook/2041 "2022-04-12T05:08:57Z")

</div>

I want to change keyboard layout when entering normal mode hook global ModeChange insert:normal %{ %sh{xkb-switch -s us} } This code in kakrc does what I need, but gives an error message: error running hook ModeChan…

---

## [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…

---

## [Mode hooks and user modes](https://discuss.kakoune.com/t/mode-hooks-and-user-modes/169)

<div class="topic-metadata">

**Author:** [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Replies:** 7\
**Last updated:** [April 26, 2021, 5:53pm UTC](https://discuss.kakoune.com/t/mode-hooks-and-user-modes/169 "2021-04-26T17:53:53Z")

</div>

Kakoune comes with a spell-checking script (spell.kak) but as is convention, it just defines a few commands and leaves the user to figure out how to incorporate them. It occurs to me that what I really want is: declare…

---

## [BufWritePost not working?](https://discuss.kakoune.com/t/bufwritepost-not-working/1681)

<div class="topic-metadata">

**Author:** [@Didac](https://discuss.kakoune.com/u/Didac)\
**Replies:** 6\
**Last updated:** [April 12, 2021, 12:44am UTC](https://discuss.kakoune.com/t/bufwritepost-not-working/1681 "2021-04-12T00:44:04Z")

</div>

Hey guys! I’ve started using Kakoune more seriously and I love it. I have some quick questions, if someone could help me out it would be awesome. First, I’m trying to make a (shell script) buffer be linted and formatte…

---

## [BufPreWrite hook dependent on buffer content](https://discuss.kakoune.com/t/bufprewrite-hook-dependent-on-buffer-content/1598)

<div class="topic-metadata">

**Author:** [@basbebe](https://discuss.kakoune.com/u/basbebe)\
**Replies:** 3\
**Last updated:** [March 16, 2021, 12:41pm UTC](https://discuss.kakoune.com/t/bufprewrite-hook-dependent-on-buffer-content/1598 "2021-03-16T12:41:26Z")

</div>

Hi! The Problem I want markdown files to get autoformatted on safe. For that, I want to use pandoc. Since I have markdown files with pandoc’s YAML markdown header and latex content, I need to consider that. Since the …

---

## [Improve \*SetOption hooks performance](https://discuss.kakoune.com/t/improve-setoption-hooks-performance/234)

<div class="topic-metadata">

**Author:** [@Delapouite](https://discuss.kakoune.com/u/Delapouite)\
**Replies:** 0\
**Last updated:** [December 13, 2018, 7:22pm UTC](https://discuss.kakoune.com/t/improve-setoption-hooks-performance/234 "2018-12-13T19:22:43Z")

</div>

Here’s a discussion started by mawww on IRC for people not there who might want to chime in: mawww For performance reasons, I need to change the way to generate the .\*SetOption hooks The problem is that dumping option…

---

## [Concepts unification: registers → options ← hooks](https://discuss.kakoune.com/t/concepts-unification-registers-options-hooks/991)

<div class="topic-metadata">

**Author:** [@Delapouite](https://discuss.kakoune.com/u/Delapouite)\
**Replies:** 4\
**Last updated:** [May 8, 2020, 7:58am UTC](https://discuss.kakoune.com/t/concepts-unification-registers-options-hooks/991 "2020-05-08T07:58:39Z")

</div>

Hello During the last few days, mawww expressed his thoughts about future Kakoune development that I found interesting to share here. …as registers are a bit transient and I imagine it would be useful to save a mark…

---

## [View active hooks](https://discuss.kakoune.com/t/view-active-hooks/901)

<div class="topic-metadata">

**Author:** [@haarts](https://discuss.kakoune.com/u/haarts)\
**Replies:** 3\
**Last updated:** [March 2, 2020, 1:21pm UTC](https://discuss.kakoune.com/t/view-active-hooks/901 "2020-03-02T13:21:42Z")

</div>

Hi all, I’m trying to write some custom hooks. Is there a way to display/show the current, active hooks for a particular scope? Something along the lines of echo %opt{...} perhaps? Thanks,

---

## [Check if hook exists](https://discuss.kakoune.com/t/check-if-hook-exists/863)

<div class="topic-metadata">

**Author:** [@FlyingWombat](https://discuss.kakoune.com/u/FlyingWombat)\
**Replies:** 2\
**Last updated:** [January 27, 2020, 9:52am UTC](https://discuss.kakoune.com/t/check-if-hook-exists/863 "2020-01-27T09:52:38Z")

</div>

Do you know of a good way to check whether or not a hook is in effect? In one of my scripts, I have a toggle command for some inter-related hooks, so it needs to use hidden options to keep track of which hooks exist. So…

---

## [Understanding a hook with exec -draft](https://discuss.kakoune.com/t/understanding-a-hook-with-exec-draft/475)

<div class="topic-metadata">

**Author:** [@ftonneau](https://discuss.kakoune.com/u/ftonneau)\
**Replies:** 4\
**Last updated:** [April 23, 2019, 8:32pm UTC](https://discuss.kakoune.com/t/understanding-a-hook-with-exec-draft/475 "2019-04-23T20:32:23Z")

</div>

Hello, I am new to kakoune – learning little by little, starting with a mininal setup (no symlink to the system-wise scripts, adding scripts only one by one to my personal autoload path) and trying to understand how thin…

---

## [Hook(s) for capturing incremental changes to a buffer](https://discuss.kakoune.com/t/hook-s-for-capturing-incremental-changes-to-a-buffer/396)

<div class="topic-metadata">

**Author:** [@bme](https://discuss.kakoune.com/u/bme)\
**Replies:** 2\
**Last updated:** [March 25, 2019, 4:30pm UTC](https://discuss.kakoune.com/t/hook-s-for-capturing-incremental-changes-to-a-buffer/396 "2019-03-25T16:30:23Z")

</div>

Why? Because I am having a crack at recreating some git porcelain for kak. I know that I could “just shell out to tig” or some other tool, but if you’ve used fugitive or magit seriously there are massive gains to be made…

---

## [Suggestion: Lazy loading with a PluginEvent hook](https://discuss.kakoune.com/t/suggestion-lazy-loading-with-a-pluginevent-hook/194)

<div class="topic-metadata">

**Author:** [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Replies:** 10\
**Last updated:** [November 27, 2018, 7:26pm UTC](https://discuss.kakoune.com/t/suggestion-lazy-loading-with-a-pluginevent-hook/194 "2018-11-27T19:26:25Z")

</div>

Kakoune’s extension system is designed to be modular rather than hyper-efficient, and while this allows plugins to be written without ceremony (“write a .kak file, stick it in this directory”), it does mean that Kakoune’…
