Make 4-space indents look like 2-space ones

已回答

I have a small plugin that doubles the visual length of space indents (using empty inlays). I was wondering if there is a workaround to do the other way around e.g. if your file is indented with 4 spaces make it look like it's indented with 2.
So far I considered folding, but It seems like that this approach is language-specific, e.g. I need a separate folder for Java and another one for Markdown...
I also looked at somehow using inlays again, but I don't see a way how to "override" the content of the editor (including the length of the region)
Are there any approaches that would make it possible? Or is the functionality that makes the tab characters elastic is available to plugin developers so I can do the same with spaces ?

0

There's no real API for that. You could try adding FoldRegion that "collapses" such places with empty placeholder. https://plugins.jetbrains.com/docs/intellij/folding-builder.html

0

Hi Yann Cebron, thank you for your answer. Is there a way to use folding in a language neutral way ? I want this plugin to work with indents in any file, not only java or python...

0

You might try registering for "all" languages, not sure it works and yields expected results
<lang.foldingBuilder language="" implementationClass="your.fqn"/>

1

The plugin Elastic Indents is able to double the indentation width or half the indentation with. Just like stretchy-spaces for VSCode.

I had to search for quite some time to find something like this and I love it, as it takes resolves these strongly opinionated discussions on indentation formats within a project.

0

请先登录再写评论。