Vertical line for suggested max line width

Hi - not sure how to describe this problem super easily, so I haven’t been able to search for a good solution on the internet.

On JetBrains IDEs I’ve used in the past, there’s a vertical line that serves as a guideline for how long a line should be. Here’s it pointed out on a random screenshot from the web:

Is there any way for me to do something similar in Kakoune? I’m writing Markdown documentation and that kind of thing is super useful to not let lines get too long, but I also don’t want to go just off screen width since that sort of thing is variable.

Quick and simple way is to use column highlighter:

add-highlighter buffer column 80 default,rgb:ff0000

where 80 is the column number and default,rgb:ff0000 is the face to use on that column.

2 Likes

awesome tysm!

Highlighting a column is the usual way to proceed in terminal-based editors. An alternative (which I find more pleasing) is to highlight a series of columns to create a colored pane on the right. For example:

Doing so requires looping over a set of column indices. Usually you would need to shell out for the loop, but here is an alternative without shell calls. The script makes uses of almr’s looping techniques:

The script is a zipped text file:

divider.zip (669 Bytes)

2 Likes

After having sourced the script (or after copying it somewhere in your autoload directory), you will be able to create a colored pane with the divider-on <column> command. The column parameter is the column where you want the colored pane to start (e.g., 81). Pane color can be customized via the divider_face option.

1 Like

Almost worked for me! I was running into issues where it was trying to delete a nonexistent highlighter (window/divider) when i ran divider-on and so I had to tweak the script slightly:

define-command -params 1 -docstring 'divider-on <column>: colorize right side starting from column' \
divider-on %{
    add-highlighter -override window/divider group
    set-option window divider_column %arg(1)
    divider-do-256 divider-colorize
} -override

Thanks, this is super helpful!

1 Like

Never had any problem on my side, but your post made me learn about the -override switch for highlighers – which is the clean way of doing it.

Is there a default face for it?, there is BufferPadding but I’m not sure they are the same thing.

No, I don’t think there is any default/common face for column highlighters (which is what the colored pane relies on).

@ftonneau, is this screenshot from you? I do like this minimalist kakoune design, with this nice lite colorscheme and custom status bar.

By any chance, do you have your config posted somewhere for inspiration?

Thanks!