You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open editor in a language that supports comments (say foo.c)
Type a line that starts with //
Press enter
Next line should automatically be started with // (or at least this should be possible to configure). Instead, the next line is empty.
Reacted by Jasin Yip, Jon Gjengset, spacegiraffe, Thijs Busser, Nacho García, Andrei Simionescu, Dennis Duda, hannesfrank, Chris Ferdinandi, Waseem Sathar and 181 more
Reacted by Helson Taveras, Kyle Chadha, Louis Pilfold, Renato de Leão, Giuseppe Crinò and René Eschke
Peng Lyu (@rebornix) If you can point me in the right direction for where to make these changes I'm happy to submit a PR for this. I like to start new files with comments laying out the code I'm going to write, so I'd get a lot of use from this.
Dalton A Mitchell (@daltonamitchell) I don't have any experience writing VS Code extensions, but here is a pull that implements it for Rust language. I also noticed that the Docker extension does it as well (although perhaps there is no concept of "block" comment in a Dockerfile):
...and JavaScript does it natively (no additional extensions) for block comments:
Not just continue comment, but when I press "Join lines" shortcut, it should remove the comment prefix from the joined line.
I remember having both of these in SublimeText and I still miss it even after yeas of vscode usage :(
You got me there! I have this feature in Vim with a comment plugin, and it's super convenient. Every time I break a long comment line or join comment lines in VS Code, I think about this feature. I assumed there might be a configuration in VS Code, and finally stumbled upon this discussion.
Hi everyone, I have the following PR #235407 which should fix this issue for the following languages that use the double-slash line comment:
cpp
csharp
go
groovy
java
json
less
objective-c
php
rust
swift
TypeScript and JavaScript already have this fix. This will add a line comment on the next line when pressing Enter only if the cursor is NOT followed only by whitespaces. This was decided as per a request from users after the fix came out for TypeScript/JavaScript. In other words, in the following case where | represents the cursor position, pressing enter will not add a line comment on the next line:
// some comment |
But in the following case it will
// some | comment
I have not added this change for C because we do not have a language configuration file for C and do not support auto-indentation natively for C. If there are other languages you'd like me to cover, with potential, other types of line comment syntaxes, please file a new issue.
This will add a line comment on the next line when pressing Enter only if the cursor is NOT followed only by whitespaces. This was decided as per a request from users after the fix came out for TypeScript/JavaScript.
Can you clarify what the purpose of this is and why it makes sense to apply to the general feature? This seems like a non-obvious special case that will confuse people, but maybe I’m missing something.
Hi Bryan Henry (@sbrocket) yes this is as a result of the following issue #233186 as well as comments in #180551 and generally feedback I have received in standup about not wanting to add a line comment on the next line if the cursor is at the end of the line followed only by whitespaces. The thought is that generally when one wants to write a multi-line comment, they'd probably use the multi-line format /* */. If however the cursor is within a line comment followed by non-whitespace characters, then we can assume the user wants to add a line comment on the next line.
Additionally this would unify the experience generally with TypeScript and JavaScript.
this is as a result of the following issue #233186 as well as comments in #180551 and generally feedback I have received in standup about not wanting to add a line comment on the next line if the cursor is at the end of the line followed only by whitespaces
I think this tells me why it was implemented this way (user feedback) but it’s still not obvious to me why people gave this feedback. What are the motivating use cases that make adding this exception better than not doing so?
The thought is that generally when one wants to write a multi-line comment, they'd probably use the multi-line format /* */.
This part feels a lot more like user preference than a safe assumption to make at the editor level. It’s not obvious to me that this is true generally for me at all.
I would guess instead that it probably depends on whatever the style happens to be in an existing codebase, and so maybe even something I may want to configure at a workspace level? It’s honestly difficult for me to be sure of without sitting down and listing out use cases for both behaviors, but at minimum, if that assumption doesn’t hold true for any user then this behavior will seem non-obvious (aka “random” in confused user speak) and so it seems like it will be really annoying to those users.
If however the cursor is within a line comment followed by non-whitespace characters, then we can assume the user wants to add a line comment on the next line.
Yes essentially the feedback I got from the users I talked to was that they don't want a line comment to be inserted on the next line when pressing Enter from the end of a line comment. I think these users use the line comment to add single line comments (as generally the line comment was designed moreso for this purpose). For those users it can be disturbing to have to remove the double slash on Enter every time. I am open to discussion however and if a lot of people in this thread would like to add this functionality we can discuss it.
Hi repulsio one way to disable this, is to install a language extension with a language configuration file that overrides the inbuilt language configuration file.
Activity
PradeepKumarRajamanickam commentedon May 17, 2017
+1 this would be nice
rebornix commentedon May 26, 2017
This should be implemented in a C extension by customizing enter rules. We may want to update our internal C extension.
daltonamitchell commentedon Dec 13, 2018
Peng Lyu (@rebornix) If you can point me in the right direction for where to make these changes I'm happy to submit a PR for this. I like to start new files with comments laying out the code I'm going to write, so I'd get a lot of use from this.
abettermap commentedon Jan 17, 2019
Dalton A Mitchell (@daltonamitchell) I don't have any experience writing VS Code extensions, but here is a pull that implements it for Rust language. I also noticed that the Docker extension does it as well (although perhaps there is no concept of "block" comment in a Dockerfile):
...and JavaScript does it natively (no additional extensions) for block comments:
Hope that helps!
17 remaining items
tim-hilt commentedon Apr 19, 2024
Same for me. I'm quite confused tbh :D cyanophage are you sure that that's not a feature of a particular language-extension you're using?
tomasklaen commentedon May 23, 2024
Not just continue comment, but when I press "Join lines" shortcut, it should remove the comment prefix from the joined line.
I remember having both of these in SublimeText and I still miss it even after yeas of vscode usage :(
yuezk commentedon Jul 22, 2024
You got me there! I have this feature in Vim with a comment plugin, and it's super convenient. Every time I break a long comment line or join comment lines in VS Code, I think about this feature. I assumed there might be a configuration in VS Code, and finally stumbled upon this discussion.
Hope VS Code will support this feature soon.
starball5 commentedon Nov 11, 2024
Related(?) on Stack Overflow: How to configure VSCode to auto insert comment chars on multi line comments
aiday-mar commentedon Dec 5, 2024
Hi everyone, I have the following PR #235407 which should fix this issue for the following languages that use the double-slash line comment:
TypeScript and JavaScript already have this fix. This will add a line comment on the next line when pressing Enter only if the cursor is NOT followed only by whitespaces. This was decided as per a request from users after the fix came out for TypeScript/JavaScript. In other words, in the following case where | represents the cursor position, pressing enter will not add a line comment on the next line:
// some comment |But in the following case it will
// some | commentI have not added this change for C because we do not have a language configuration file for C and do not support auto-indentation natively for C. If there are other languages you'd like me to cover, with potential, other types of line comment syntaxes, please file a new issue.
sbrocket commentedon Dec 5, 2024
Can you clarify what the purpose of this is and why it makes sense to apply to the general feature? This seems like a non-obvious special case that will confuse people, but maybe I’m missing something.
aiday-mar commentedon Dec 5, 2024
Hi Bryan Henry (@sbrocket) yes this is as a result of the following issue #233186 as well as comments in #180551 and generally feedback I have received in standup about not wanting to add a line comment on the next line if the cursor is at the end of the line followed only by whitespaces. The thought is that generally when one wants to write a multi-line comment, they'd probably use the multi-line format /* */. If however the cursor is within a line comment followed by non-whitespace characters, then we can assume the user wants to add a line comment on the next line.
Additionally this would unify the experience generally with TypeScript and JavaScript.
sbrocket commentedon Dec 5, 2024
I think this tells me why it was implemented this way (user feedback) but it’s still not obvious to me why people gave this feedback. What are the motivating use cases that make adding this exception better than not doing so?
This part feels a lot more like user preference than a safe assumption to make at the editor level. It’s not obvious to me that this is true generally for me at all.
I would guess instead that it probably depends on whatever the style happens to be in an existing codebase, and so maybe even something I may want to configure at a workspace level? It’s honestly difficult for me to be sure of without sitting down and listing out use cases for both behaviors, but at minimum, if that assumption doesn’t hold true for any user then this behavior will seem non-obvious (aka “random” in confused user speak) and so it seems like it will be really annoying to those users.
Yes this part does seem like a safe assumption.
aiday-mar commentedon Dec 6, 2024
Yes essentially the feedback I got from the users I talked to was that they don't want a line comment to be inserted on the next line when pressing Enter from the end of a line comment. I think these users use the line comment to add single line comments (as generally the line comment was designed moreso for this purpose). For those users it can be disturbing to have to remove the double slash on Enter every time. I am open to discussion however and if a lot of people in this thread would like to add this functionality we can discuss it.
aiday-mar commentedon Dec 13, 2024
This issue will be closed. Feel free to open other issues if there is something else.
repulsio commentedon Dec 19, 2024
Aiday Marlen Kyzy (@aiday-mar) How to disable this? This new feature is really disruptive to me
aiday-mar commentedon Jan 6, 2025
Hi repulsio one way to disable this, is to install a language extension with a language configuration file that overrides the inbuilt language configuration file.