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

Convert indentation from 2 to 4 spaces #1

Open
rchl opened this issue Mar 29, 2020 · 4 comments
Open

Convert indentation from 2 to 4 spaces #1

rchl opened this issue Mar 29, 2020 · 4 comments
Labels
wontfix This will not be worked on

Comments

@rchl
Copy link

rchl commented Mar 29, 2020

Sometimes I have code using 2 spaces for indentation that I want to convert to 4 spaces.

What I do is convert to tabs first, convert to tab-width 4 and convert back to spaces.
The problem with that is it changes alignment and can break the code with indentation-sensitive languages (python).

Would such functionality be in the scope of this package? Judging from the name maybe not as it deals with converting from "tabs" :)

@maliayas
Copy link
Owner

For what I understand, your method should solve the problem. Can you give a specific example?

If your original code is indented with 2 spaces, that should mean your inline alignments are also based on spaces. When you convert indentation using Sublime Text's status bar menu, it would modify only leading spaces, not initial spaces that you put for alignment. Then modify indentation level and convert to space from tab using the same Sublime menu should give you expected result.

If you post an example here which doesn't work, I can look into it.

@rchl
Copy link
Author

rchl commented Apr 11, 2020

Something like that would break when converting from 4 to 2 spaces:

def main():
    foo = settings.get("foo",
                       None)

You would end up with:

def main():
  foo = settings.get("foo",
             None)

@rchl
Copy link
Author

rchl commented Apr 11, 2020

OK, that example would only break in a stylistic way, not functional. There are other cases that would break functionally. I can find one if you want but I think you get the idea.

@maliayas
Copy link
Owner

Hmm, I see. That's irregular spacing and would require significant work to detect and preserve them (and I feel that still it wouldn't be 100% perfect).

Actually I consider it in the scope of this plugin, because it would happen for tab-to-space, as well. But I personally don't use that sort of styling and unfortunately I'm not willing to work on it at the moment. But let's keep the issue open for further discussion; maybe someone in the future wants to grab it and give it a try.

@maliayas maliayas added the wontfix This will not be worked on label Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants