helix
helix copied to clipboard
It would be nice to have a `trailing` option for rendering spaces and tabs
Describe your feature request
Additional setting for [editor.whitespace.render]
Currently spaces and tabs have 2 possible settings in config: space = "none"
or space = "all"
and tab = "none"
or tab = "all"
.
I think it woud be beneficial also to have a setting space = "trailing"
and tab = "trailing"
to visualize only trailing white spaces/tabs
If this was to be added, I think it would also be useful to have a "leading" option for people who use leading whitespace to keep track of which level of indentation they're in.
Also perhaps a specifier at the [editor.whitespace.render]
level for these options:
[editor.whitespace]
render = "trailing"
# render = "leading"
If this was to be added, I think it would also be useful to have a "leading" option for people who use leading whitespace to keep track of which level of indentation they're in.
how to deal with different cardinality of settngs in this case? all
and none
can happen only by themselves
leading
and trailing
can happen by themselves, or in tandem, but cannot be combined with all
and none
?
Indent guides https://github.com/helix-editor/helix/pull/1796 are probably more appropriate for tracking indentation levels than visible whitespace
Also, it would be great if the theme could have different colors for trailing and leading whitespace. For example a faded color for leading and strong for trailing.
I think this can be solved with theming rather than adding options to render only leading/trailing whitespace. Trailing whitespace could be themed ui.virtual.whitespace.trailing
for example and this could be set to something noticeable on a per-theme basis. With this approach you could view leading/trailing whitespace without having visible whitespace turned on.
I do like the idea of theming, howerver would also be great to be able to toggle this setting when trailing/leading spaces mean something different, like in CSV files, or because of a user preference.
as @archseer mentioned in chat:
this would add some overhead to the rendering since you'd need to track exactly where the last non-whitespace char is to determine if a space is trailing or not
Would toggle help here as well? So for people who do not need the feature, or who disabled it for a time-being it does not slow down the performance, and for people who need it, it is available.
Indent guides are one thing, but they don't help to spot mixed indentation. If I have listchars
set reasonably in Vim, a line starting with spaces looks differently than one starting with tabs, and it should be, as spaces have no place in indentation for me.
Additionally, I'd like to have characters for precedes/extends (parts of the line hidden when it's too long), multispace (more than one space after the other) and EOL. Well, basically, I'd like to have everything I can do with listchars
in Vim 🤷♂️
Hi, indeed being able to visualize trailing spaces would be awesome.
Just a heads-up, I opened a PR some time ago, it implements trailing whitespace in an efficient way. Here's the PR: https://github.com/helix-editor/helix/pull/4306 I've been using it since then without a problem.
I think this can be solved with theming rather than adding options to render only leading/trailing whitespace
this seems to make sense for the different "weighting" that other ppl suggested - having different weights by default seems overkill...
I also like the idea of having leading whitespace rendered if it is less spaces than the indentation of the file.
For example, if your indentations are at 4 spaces, and you start writing a line which has 3 spaces only, then they are rendered. Or if you have a new line with 6 spaces, then one indentation guide is rendered, and the remaining 2 spaces are rendered.
"Trailing" in the title brought in discussion of "leading", and now my request has to do with "in the middle", though I wonder if I should start an entirely new issue for it or not. It would also be nice to be able to configure to only render spaces in the middle of a line if there are more than one consecutive space. e.g. VSCode allows it, and its capability was mentioned in a request for similar capability in vim: https://stackoverflow.com/questions/58152552/render-space-if-it-have-multi-space-in-vim For me, it is helpful to visually see that there are unnecessary, (typically accidental) extra spaces in the middle of a line. (edit addition --> ...without the overbearing dot for the [usually correct, single] space between every word.)
This issue overlaps with https://github.com/helix-editor/helix/issues/1068
Indent guides #1796 are probably more appropriate for tracking indentation levels than visible whitespace
Perhaps some people prefer it. Leading, trailing, and non-single space visualization are useful and nice-to-haves to some people.
Because of the unexpected way, yes the expected way is VS Code and Vim, indent guides and whitespace are handled, I use tab characters with a bar to identify if a space is mixed in.
[editor.whitespace.render]
nbsp = 'all'
tab = 'all'
# space = 'all'
[editor.whitespace.characters]
space = '·'
tab = '│'
# tabpad = '→'
Another option is using indent guides with tabs hidden and showing all space characters.
tabpad also has unexpected behavior, more to do with how indents are handled by lsp config.
Edit: this bar character is thin and center aligned
Showing trailing spaces would be nice!
Did anything ever come of this? I would like to be able to show leading and trailing whitespace also
There is an open PR for this: https://github.com/helix-editor/helix/pull/7215 You can merge it in your own fork and compile from source if you're interested in this feature.
That PR appears to be for trailing whitespace - I'm mostly interested in leading!