Skip to content
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

Display 2 spaces instead of 4 without changing the code or project settings #132776

Open
seahindeniz opened this issue Sep 9, 2021 · 17 comments
Open
Assignees
Labels
editor-rendering Editor rendering issues feature-request Request for new features or functionality
Milestone

Comments

@seahindeniz
Copy link

Hi, I'm working on projects that requires 4 space indentation, but I find this rule is a bit irritating. Is it possible to have an option to change the displaying/rendering behavior to show 4 spaces as 2 space without actually changing the spaces in the code. Such functionality would also need to work when I want to create a new file with projects indentation requirements, but would still render 4 spaces as 2.

@alexdima alexdima added editor-rendering Editor rendering issues feature-request Request for new features or functionality labels Sep 9, 2021
@buondevid
Copy link

I guess my feature request is really similar to this one: I'd like to see 2 spaces as 4 (so for the opposite reason of this request) without changing the actual code because I prefer a more stretched out view.

I thought a good solution would be to control the width of one indentation space in pixels for instance.

@ceoshikhar
Copy link

@seahindeniz @buondevid Checkout https://marketplace.visualstudio.com/items?itemName=kylepaulsen.stretchy-spaces, might be helpful.

@seahindeniz
Copy link
Author

seahindeniz commented Jan 4, 2022

Hey @ceoshikhar thanks for the suggestion!
I just installed it and gave it a try however, the extension has some issues with rendering codes, guidelines, and I assume this is because of the insufficient API support.

The extension isn't compatible with built-in guidelines and has rendering issues, so it suggests another extension, which has noticeable bugs as well.

  • When I set stretchySpaces.targetIndentation to 2 spaces on a project that has 4 spaces indentation, the Stretchy extension renders the code like the following:
    image
    which should've been like this:
    image

  • When you scroll down, guidelines doesn't get re-render. You have to click in order to trigger rendering. I've opened an issue: Guidelines don't get rendered after scrolling spywhere/vscode-guides#67

  • Empty lines don't get guidelines rendered due to some restriction, which is not good and doesn't look organic

Better yet, I would like this feature to be added to VSCode as a built-in feature, rather than having an extension that depends on APIs that doesn't give full support to line rendering functionality

@dsherret
Copy link

dsherret commented Jun 28, 2022

This issue would improve accessibility as it would allow people to more easily view repos that use spaces. There is an issue in prettier about switching to tabs by default (prettier/prettier#7475), but it's not a real fix for the accessibility concerns compared to something like this (along with improvements to other tooling such as GitHub's rendering).

@xenago
Copy link

xenago commented Jun 29, 2022

A suggestion like this is an actual fix for accessibility concerns, unlike suggestions elsewhere to change entirecodebases over! Can we get this added in such a way so that x-spaces can be folded into y-spaces or a tab in a configurable manner? I think many braille users would appreciate being able to fold 4 spaces into a tab, for example.

@ljharb
Copy link

ljharb commented Aug 15, 2022

It would indeed be great for viewers of a repo that has chosen spaces not to have to suffer from that choice - the best choice is that they use tabs, but this sounds second-best.

@MattiasMartens
Copy link

i would like to see this too.

i am a newbie to ligatures, but can a ligature solve this? i.e. render 4 spaces to a ligature of width 2.

@buckley310
Copy link

Can we get this added in such a way so that x-spaces can be folded into y-spaces

I would think something like an "indentation multiplier" makes sense.

Either a manual setting that people can set to 2.0 or 0.5, or an automatic multiplier based on the detected indentation of the file vs the user's desired indentation.

Each indentation character would have its width multiplied by that.

@ArthurBrussee
Copy link

Another +1 to this. Everyone has their own preference for 2/4/3(??) sized indents. Reading all code at work, home, and various languages at the same indent size could really help to pattern detect quickly and ease in to new languages. With the recent work to make spaces act as tabs as much as possible, it seems this might be really close!

@SandraSaliger
Copy link

fully agree! same request here!

@sjors-bootmine
Copy link

bump!

@ViewableGravy
Copy link

+1. My company has coding guidelines that require indentation to be 4 spaces but I prefer 2 spaces. Simply being able to visually change this without conflicting with the codebase would be amazing!

@jjjuk
Copy link

jjjuk commented Oct 3, 2023

Yes people, I need this one like an air. I've got brain damaged from 4 tabspaces today. Wish me better mental health.

@foolo
Copy link

foolo commented Jun 17, 2024

Darn, if only there were a special character that could change width depending on the user's preference :)

@AndreiRegiani
Copy link

Temporary workaround: https://github.com/kylepaulsen/vscode-stretchy-spaces
(It's buggy)

It would be fantastic for this feature to be natively supported.
Is there a configuration for this am I missing?

I'm editing a 2-space codebase but I'd prefer to render as 4-spaces without affecting the source code file.

@yamplum
Copy link

yamplum commented Jul 11, 2024

Darn, if only there were a special character that could change width depending on the user's preference :)

It would be nice if VS Code could take code indented with spaces and render it with tabs on the fly without changing the underlying file. I doubt there's significant use for leading spaces that aren't a multiple of the indentation level anyway. This would be very helpful for people like me who use a proportional font for coding, since spaces in proportional fonts are typically pretty narrow.

@Mateo-EBA
Copy link

+1 !
Letting each user see code however they prefer without modifying the actual file is always a plus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-rendering Editor rendering issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests