-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable rendering of invisible characters like space, tab, and line feed #1068
Comments
Usually the most annoying invisible characters are those at the end of the line. In my opinion an option to highlight only these is very useful. |
Perhaps the config option could allow things like this: Render all whitespace[editor]
render-whitespace = "all" Render all newlines[editor]
render-whitespace = { newline = "all" } [editor.render-whitespace]
newline = "all" Render all newlines, render other whitespace when selected[editor]
render-whitespace = { default = "selection", newline = "all" } [editor.render-whitespace]
default = "selection"
newline = "all" |
We definitely could take some user experience from vscode, last time I used it setting this part they have some sort of presets, we could do that with what you showed. [editor]
render-whitespace = "all" And when customization is needed, we can can always fall back to [editor.render-whitespace]
default = "selection"
newline = "all" Thinking aloud, should we also let the users choose the characters of their choice like what you can do in vim? Should we also allow theming this one? Since I sometimes see different foreground and background color for these texts, like in doom emacs? |
Yeah, this definitely should be a theme thing. |
I would also like the option to only render trailing whitespace, i.e. spaces at the end of a line with no other characters following them. |
In addition to trailing whitespace, VSCode has a useful option to show boundary whitespace, e.g. double space. Ideally, the option would also allow to show both trailing and boundary whitespace beside just one or the other. |
I have found |
@divarvel I gave implementing a boundary whitespace renderer a go; it's on this branch here: https://github.com/mtoohey31/helix/tree/feat/boundary-whitespace. If you happen to have time, would you mind trying it out and letting me know if it works the way you'd expect? To enable it, running |
Wow, thanks! I gave it a go and it works as documented indeed. I wonder if your work could be adapted to provide support for I can have a go at it and see how it goes. |
The main issue with Here's my attempt: divarvel@2ef08c1 pros:
cons:
It depends on @mtoohey31's patch (which i believe only supports |
Nice idea @divarvel, that's an interesting solution! The challenges you mentioned with trailing are actually why I decided to give boundary a shot first; I'd perfer trailing myself too. It might still be worth checking how much the double traversal solution would impact performance, because it might not be too bad. Or, we could give this kind of whitespace rendering a different name other than "trailing" and add it now, then if we come up with a performant implementation for what other editors refer to as "trailing", that could get added later under that name without changing the behaviour of an existing option. I don't know if I'll get around to working on this again any time soon. Don't feel like you need to wait for me if you'd like to create a PR, if you want to create a PR based on my chanes that's fine with me. Not sure how the changes in #5420 will play with our changes though; I haven't checked but the mention of "rework rendering" in the title suggests that there might be significant conflicts. |
The text rendering code was completely replaced so your code would likely require significant changes. |
Ok, that's alright. Thanks for your work on that PR by the way @pascalkuthe, I've been waiting for softwrap for a long time! |
Is it possible to only show invisibles in normal mode? Or to have a mode-specific configuration for when invisible whitespace is shown? Plus, I want my cursor to change colour depending on whether the cursor is on a newline character. I don't know about you, but because you can select both whitespace and newline, wanting to delete whitespace, you can accidentally delete a newline, and I find that I want the cursor to just change the colour if I am on a newline character so I know whether or not I want to delete it. To me, this strikes a balance between not being able to select a newline character (vim) and being able to know you're on a newline. Finally, this is a bit tangential, but I find the "soft-wrapped newline" symbol kind of unnecessary in soft-wrap. This is for a different issue, but I don't really want to know that a line is soft-wrapped because line numbers already show that. |
Regarding the "soft-wrapped newline" symbol, you can configure that to any string you like using |
I too would like an option to show trailing whitespaces only, because showing all whitespaces adds a lot of clutter. I quite like the solution proposed by @divarvel, also I reimplemented it on master if someone else is interested: jean-dao@3d0e232 (there's also an additional commit to have a separate style for newlines jean-dao@b026823) |
@jean-dao I like this! would you make a PR for it? |
Some config option for whether to display invisible characters like rendering spaces as dots, tabs as arrows, etc.
The config option would have 3 possible values:
none
: Don't render invisible characters.selection
: Render invisible characters that fall into a selection.all
: Render all invisible characters.I presume this would also add a field to themes?
The text was updated successfully, but these errors were encountered: