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

Code Style: Indentation settings? #35

Open
fritzw opened this issue Dec 13, 2022 · 3 comments
Open

Code Style: Indentation settings? #35

fritzw opened this issue Dec 13, 2022 · 3 comments

Comments

@fritzw
Copy link

fritzw commented Dec 13, 2022

I'm trying to implement a few features that I hope you would find useful. However, the current indentation style with tabs vs. spaces appears rather random (see attached screenshot from CirSim.java). It looks okay when setting the Tab width to 8 and indenting by 4 spaces, but sadly that is not possible in VSCode right now (microsoft/vscode#5394), in contrast to e.g. vim. :-(

@pfalstad: Do you prefer any specific indentation style for new contributions? I understand that unifying all the old code would mess up the git history, so that is out of scope. In the absence of any guidelines I would use spaces-only for new code because editors can't mess that up and using tabs consistently leads to messes.

image

@pfalstad
Copy link
Owner

pfalstad commented Dec 14, 2022

I prefer tabs set to 8, with 4 space indent. (spaces only is OK.) That is what all the java code originally used. I think that got messed up somewhere. Perhaps Iain was using different settings, or maybe I was using the wrong settings in eclipse for a while.

@fritzw
Copy link
Author

fritzw commented Feb 7, 2023

Adding a .editorconfig file to the repository could help people get the settings right. VS Code just recently got the ability to separately set the indent width and the tab width. Unfortunately the EditorConfig plugin seems unable to set these settings correctly for now (editorconfig/editorconfig-vscode#346), but at least I can set them manually to correctly render the Java files.

Also, VS Code will not automatically merge 8 spaces into a tab. This could be done with an automatic replace-on-save action, but that would affect the entire file, not just changed parts. Guess we will have to live with inconsistent spacing.

But since you said that spaces only are fine for you, we can probably close this issue. Or leave it open until a working .editorconfig has been commited.

@H-Dynamite
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants