V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
flyinghigherair
V2EX  ›  Visual Studio Code

vscode html 代码 单行注释 块注释

  •  
  •   flyinghigherair · 2023-04-18 11:52:29 +08:00 · 1981 次点击
    这是一个创建于 367 天前的主题,其中的信息可能已经有所发展或是发生改变。
    https://i2.100024.xyz/2023/04/18/j1fw0k.webp
    之前一直在用 webstorm ,默认 html 部分是每行注释,偶尔需要 vscode 编辑发现都是块注释很不方便,网上搜了一圈没找到是哪里设置的(有搜到行注释和块注释快捷键但还是整段注释的),求问这个设置的办法是?
    7 条回复    2023-04-18 16:27:49 +08:00
    Alias4ck
        1
    Alias4ck  
       2023-04-18 12:36:23 +08:00   ❤️ 1
    先选中用 shift+option(mac) 选中所有行的开头 拉到每一行的行尾 再 command+/ 即可多段单行了
    或者直接 shift+option+i 直接定位到行尾 再 command+/ 也可以

    这个链接的第一个动画就是上述操作了
    https://qawithexperts.com/article/technology/how-to-comment-multiple-lines-in-visual-studio-vs-code/443

    也可以安装外部插件
    https://www.taeluf.com/blog/vs-code/single-line-comments/ (要安装 multi-command extension)
    https://marketplace.visualstudio.com/items?itemName=8rin5x.onelinecomments
    DOLLOR
        2
    DOLLOR  
       2023-04-18 13:55:41 +08:00   ❤️ 1
    用鼠标中键来选要注释的行,再按注释快捷键,这样每行都是单独的注释了。
    jiayouzl
        3
    jiayouzl  
       2023-04-18 15:10:38 +08:00
    @Alias4ck 你有点东西
    daolanfler
        4
    daolanfler  
       2023-04-18 15:27:29 +08:00
    @Alias4ck 用了这么多年 VS Code 才发现还有这种通过鼠标拖动的多光标编辑
    daolanfler
        5
    daolanfler  
       2023-04-18 15:35:17 +08:00
    如果用 vim 插件可以 ctrl+v 进入块选择,选择多行,然后 ctrl(cmd) + / 也可以单行注释 html
    flyinghigherair
        6
    flyinghigherair  
    OP
       2023-04-18 15:50:34 +08:00
    感谢 1 楼和 2 楼的回复
    不过 shift+alt+a 貌似只能在 js 区域生效? html 区域两种注释还是都只有头尾
    2 楼的方法可以,不过 css 部分还是头尾注释的
    Alias4ck
        7
    Alias4ck  
       2023-04-18 16:27:49 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2885 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 02:40 · PVG 10:40 · LAX 19:40 · JFK 22:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.