Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure VSCode to auto insert comment chars on multi line comments

Is there a way to configure VSCode so that I can write multi line comments.

In Rust comments start with // or ///. If I write such a comment then it would be nice when I hit Enter that the editor auto insert /// in the beginning of the new line.

like image 913
zzeroo Avatar asked Apr 21 '17 12:04

zzeroo


People also ask

How do you comment out multiple lines of code in VSCode?

If you select a block of code and use the key sequence Ctrl+K+C, you'll comment out the section of code. Ctrl+K+U will uncomment the code.

How do you comment multiple lines of code at once?

To comment out multiple code lines right-click and select Source > Add Block Comment. ( CTRL+SHIFT+/ ) To uncomment multiple code lines right-click and select Source > Remove Block Comment. ( CTRL+SHIFT+\ )

How do you add a character to multiple lines in VSCode?

Windows: Ctrl + Alt + Arrow Keys. Linux: Shift + Alt + Arrow Keys. Mac: Opt + Cmd + Arrow Keys.


2 Answers

Update from 2020: The rust-analyzer extension now has support for comment continuation on pressing Enter, although it is not enabled by default.

As an alternative, the Auto Comment Blocks extension seems to provide this for multiple languages, Rust included.

like image 135
Matěj Laitl Avatar answered Oct 15 '22 18:10

Matěj Laitl


There is no setting in VSCode to do this. It's a Language feature, and must be developed by the extension that gives support to the language.

I looked at two Rust extensions (Rust and Rust Code) but none of them presents this feature. You should fill an issue on your extension's repo.

like image 35
alefragnani Avatar answered Oct 15 '22 18:10

alefragnani