Warn when lines are over a certain length

Hey, is there a way to have visual feedback (for example, coloured background) if a line goes over a certain length (for example, 72 characters) ? Right now, i just force kakoune in tmux to be at a certain width, but that’s a bit annoying, and i’d rather something cleaner

Hey,

According to

:addhl window/ column 72 default,rgb:404040

Should be the equivalent to colorcolumn in vim. It displays a bar on line 72.

So adding

hook global WinCreate .* %{
    addhl window/ column 72 default,rgb:404040
}

In kakrc should probably add one by default.

I have the following in my kakrc:

add-highlighter global/ column \
    '%sh{echo $(($kak_opt_autowrap_column + 1))}' \
    +r@Whitespace

Instead of hard-coding the column to 72, it uses shell arithmetic to set the column to “the autowrap_column option plus 1”, so it automatically adjusts to respect filetype plugins that set different wrap widths. For example, emails get wrapped at 72 columns, and Python at 80.

I don’t actually use the autowrap plugin itself, really, but its option is a useful convention for this kind of thing.

how often is this shell script executed? each window creation? each “screen refresh”?

I don’t actually know. I have another, different fragment in my kakrc that displays the Unicode codepoint of the character under the cursor, and that causes a shell script to be executed on every keypress. It doesn’t seem to cause any observable delay on my decade-old hardware, so I’m not too worried about it.

I tested it. The property is read each keystroke, so the script execution follows the same frequency. This is very interesting. It offers more advanced setup possibilities.