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

Commenting out code #53

Open
andrewbaxter opened this issue Feb 3, 2023 · 1 comment
Open

Commenting out code #53

andrewbaxter opened this issue Feb 3, 2023 · 1 comment

Comments

@andrewbaxter
Copy link
Owner

The basic issue is // is ambiguous to whether what follows is for humans (markdown) or commenting out code (literal). So I chose the human one, since the former needs automatic formatting (and this project's all about formatting things automatically) and the latter is I feel probably rarer and kind of a WIP hack thing so I thought it was less important.

One option is to treat /* as verbatim, but editors that have a hotkey for commenting blocks of code vary in whether they do // or /* which reduces the effectiveness, and it's not like people can't use /* for human comments either.

My current solution is I introduced a new //. verbatim comment style, but another solution would be good. At the very least adding /*. for consistency would probably be a good move.

This issue is about coming up with a full solution though.

@AaronKutch
Copy link

AaronKutch commented Feb 4, 2023

Interesting ideas. 99% of the time when I use /* it is for commenting out code or special text that I don't want formatted. Rustfmt doesn't do anything ever to /* and prints errors if /* comments exceed line length limits, which I feel is the best approach for them. One thing about commented out code in // is that it either has a lot of leading spaces for indentation or has a lot of trailing ;s.
What I do in VScode sometime is ctrl+/ which doubles up the // if I commented a comment.
e.x.

    // // comment
    // let mut file0 = std::fs::OpenOptions::new()
    //     .truncate(true)
    //     .write(true)
    //     .create(true);

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

2 participants