Inconsistent TAB character spacing in edit mode

This is probably quite nitpicky, but something that hopefully won’t be too complicated to fix.

When editing a note within Notenik, I’ve noticed, and now cannot ‘unsee’ that a tab character is not a fixed number of characters, when the edit font is monospaced.

I would expect it to be 4 spaces, but as you can see below, its between 2 and 3 characters:

notenik

Same text in Vim:

vim

Good feedback!

Unfortunately, I don’t see an easy way to make a tab character take up exactly 4 spaces, other than, possibly…

Converting every tab character encountered to four spaces (which might be more doable, based on some preliminary Googling).

Would this be helpful, perhaps as an Application setting?

Would this be helpful, perhaps as an Application setting?

It wouldn’t be for me personally.

I keep a lot of code snippets in my notes and generally use tabs instead of spaces.

And so wouldn’t want these converted into spaces.

Unfortunately, I don’t see an easy way to make a tab character take up exactly 4 spaces

Out of curiosity, is that a SwiftUI issue? Or because the base is a rich text editor, just with a monospaced font?

As I notice the same issue in the new Apple Notes. Whereas the old Text Editor is like a terminal, exactly 8 spaces in a tab when in ‘Plain text’ mode. I’m assuming it’s still in Cocoa.

I was just about to ask if you could add the tab width rendering option.

Before a quick search gave me the tab-size CSS property. Which I’d never used in 20 years of developing websites.

Well, Notenik is developed completely using Cocoa – no SwiftUI here! So the issue is more the second one you identified – Cocoa basically provides a rich text editor (although I’ve got it set to plain text), and is somewhat oblivious to the fact that it’s currently using a monospaced font.

And of course the CSS options only work on the Display tab, not on the Edit tab.

But I think I may have just stumbled across some code that might work.

I will give it a try later today (hopefully) and let you know how it goes.

I think I’ve wrestled this one to the ground! Try out the new beta and let me know how it goes.

Thanks! Looks good to me – haven’t come across any ill effects yet.

1 Like

Great! Glad I was able to figure it out. It’s always nice to eliminate small (but significant!) annoyances.