0

Change text underline positions in Kitty terminal emulator

 1 year ago
source link: https://benfrain.com/change-text-underline-positions-in-kitty-terminal-emulator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Change text underline positions in Kitty terminal emulator

06.09.2022 0 comments
0 days since last revision. Content should be accurate.

I think Kitty is the best Terminal emulator available. This opinion was re-enforced when I discovered that Kitty now has the option to modify fonts. Why would anyone care about that?

I have wrote in the past how Kitty provides a facility to set a font for unicode characters, so you never need to patch a font again. This is not that.

I’m talking about the ability to amend things like the position of underlines. The thing is, I use Kitty to run Neovim so much of my day is spent in Kitty. I use Victor Mono currently and when using the indent-blankline plugin, when you hover on a suitable section, it reveals the relevant indent. But this is what is looks like ordinarily.

Misaligned line in Kitty
By no means terrible but we can do better!

Which is not terrible but that gap can be fixed to look like this:

How to modify the font

You will need to look at the modify_font section of the Kitty documentation. Here you can see a bunch of magical properties. The ones I added to my config were:

modify_font underline_position 9
modify_font underline_thickness 150%
modify_font strikethrough_position 2px

And that gives me nice thick underlines in the position I want them. There are other settings but these are the only ones I needed. So far so good. That gives me this:

But still that gap at the side. Thankfully that can be changed in the indent-blankline settings.

Changing the line in indent-blankline

We can set a different glyph for the line. The default one sits in the center of the glyph so we can change to one that sits at the left:

require("indent_blankline").setup({
  space_char_blankline = " ",
  show_current_context = true,
  show_current_context_start = true,
  use_treesitter = true,
  use_treesitter_scope = true,
  char = "▎",
})

The char being the relevant part there. And with that set I have underlines exactly where I want them in normal text and nicely aligned lines in Neovim. And I don’t wake up in the dead of night screaming “ALIGNMMMENNNNTTTTTTTTTT!”.

Kitty line aligned correctly
With Kitty’s options and an amended glyph we have perfection

Summary

This is a level of pedantry that isn’t for everyone but the level of customisation and power possible in Kitty never ceases to surprise me.

If this post was useful, Say thanks with a coffee. Every donation helps keep me going! 🙏

Latest Book Responsive Web Design with HTML5 and CSS

The 3rd Edition of the best—selling 'Responsive Web Design with HTML5 and CSS'.

Amazon Packt

How to modify the fontChanging the line in indent-blanklineSummary


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK