6

How do I make the Kakoune text editor display line numbers?

0

3 Answers 3

5

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 }

4
  • 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.
    – user142
    Nov 22, 2017 at 14:55
  • It looks like my version is just too old. addhl number_lines works for my version.
    – user142
    Nov 22, 2017 at 15:09
  • 7
    As of 2018 (Kakoune v2018.10.27), I had to type add-highlighter global/ number-lines
    – Nate
    Dec 7, 2018 at 18:59
  • @Nate You should post answers as answers, not comments. Jan 20, 2019 at 17:12
4

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.

1
  • Thanks, finally working :)
    – xeruf
    Nov 22, 2020 at 21:08
0

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.

1
  • 1
    Better just to put add-highlighter global/ number-lines in your kakrc, surely. Apr 27, 2021 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.