How do I make the Kakoune text editor display line numbers?
3 Answers
On latest Kakoune versions, you can enable line numbers for every buffers by putting the number_lines
highlighter inside the global scope, with the following command:
add-highlighter global number_lines
If you want more control, another solution is to use a hook to add the number_lines
highlighter on specific windows, for example if you line numbering only on buffers whose names do not contains *
(as these are usually internal buffers), you can add a hook that does just that:
hook global WinCreate ^[^*]+$ %{ add-highlighter window number_lines }
-
This does not work for the version I installed from the official Ubuntu 17.04 repositories. However, it works if you compile kakoune from source.– user142Nov 22, 2017 at 14:55
-
It looks like my version is just too old.
addhl number_lines
works for my version.– user142Nov 22, 2017 at 15:09 -
7As of 2018 (Kakoune v2018.10.27), I had to type
add-highlighter global/ number-lines
– NateDec 7, 2018 at 18:59 -
As of 2020-11,
Kakoune v2020.09.01
the following is working:
add-highlighter global/ number-lines
Make sure you're typing spaces exactly as in the snippet above.
Originally provided by Nate on Dec 7 '18 at 18:59 for Kakoune v2018.10.27.
Expanding on Marek Kowalczyk's wonderful answer, if you want to enable line numbers everytime you launch kakoune, I find that going into your .bashrc and entering:
alias kak="kak -e 'add-highlighter global/ number-lines'"
helps a lot in getting line numbers everytime you go into a file with kakoune. Not only that, but with this method you have immediate access to disabling this command and tweaking it however you desire.
man kak
if you want to learn more about this command.
-
1Better just to put
add-highlighter global/ number-lines
in your kakrc, surely. Apr 27, 2021 at 13:54