[英]Is there a shortcut to comment multiple lines in python using VS Code?
Instead of indivually typing out a hash tag in front of each line, is there a way to select a block of code and comment/uncomment everything by only pressing a couple shortcut keys?不是在每行前面单独输入 hash 标签,有没有办法通过按几个快捷键来 select 代码块和注释/取消注释所有内容?
Select all of the lines and do one of the following: Select 所有行并执行以下操作之一:
All shortcuts:所有快捷方式:
All you need to do is select that code block with your mouse, then press the following key combination:您需要做的就是使用鼠标进行代码块 select,然后按以下组合键:
Ctrl + K then press Ctrl + C if you're using Windows Ctrl + K 然后按 Ctrl + C 如果您使用的是 Windows
Command + K then press Command + C if you're on a Mac Command + K 然后按 Command + C 如果您使用的是 Mac
You can also use:您还可以使用:
Ctrl + / to comment and uncomment lines of Python code on Windows. Ctrl + / 在 Windows 上注释和取消注释 Python 代码行。
Command + / to comment and uncomment multiple lines of Python code on Mac. Command + / 在 Mac 上注释和取消注释多行 Python 代码。
I think the answers above all ignore a key piece of information the OP asked: multiple lines .我认为最重要的答案忽略了OP询问的一个关键信息:多行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.