You do have to select the complete line if you want the entire line commented. html files but you can see how to include other extensions in the other when clause. "when": "editorTextFocus & editorHasSelection & resourceExtname =~ /\\.html/" "when": "editorTextFocus & editorHasSelection & resourceExtname =~ /\\.(html|css|scss)/" Use Ctrl + / to comment out and uncomment the code that you highlight. Goto File > Preferences > Keyboard Shortcuts. If you are manually commenting out each line at a time, it is time to switch up. You can edit your preferences on VS code. If it is US keyboard then, The shortcut key might have changed. Change the Keyboard layout to US-Keyboard if US keyboard is not selected. It break your your selection into separate lines and then toggles a block comment on each line.Īdd the keybinding to trigger that macro - over-loading the ctrl+ / keybinding (put this in your keybindings.json): , First of all see which keyboard layout you are using on your System. "command": "multiCommand.blockHTMLCommentByLine", Put this into your settings.json: "mands": [ You will have to use a macro command, here I used multi-command, to break the lines apart and apply a block comment to each. Yes, vscode can do block comments by line but that functionality is not built-in. Here is a demo on your code that works well: I just made an extension, Toggle Line Comments, that uses your "dumb approach" to toggle each line individually. It was just a random block that I used for this example. Please ignore the fact that the html is invalid. a dumb commenter that just comments/uncomments every line individually like so:.a "smart" commenter that can use the block comments & "know" whether it's currently in a comment or not.Don't have the problem in PHP code, since that uses // to comment line-by-line How can I change this behavior? I have the same problem when I ctrl + / CSS Code blocks. These shortcuts include keyboard and mouse shortcuts as well as text you can enter to help accomplish a task more easily. You can navigate in Visual Studio more easily by using the shortcuts in this article. Or, if you dont want to do that, you can do this trick in VScode or replit: You can do ctrl + / to comment lines, or select the specific text you want to. Selected a chunk of code & ctrl+/ to uncomment a single line, but it just adds a new comment, thus breaking the larger comment Applies to: Visual Studio Visual Studio for Mac Visual Studio Code.Selected the whole block of code & ctrl+/ to comment the whole thing.Here's an example of me using ctrl + / to comment HTML code in VS Code:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |