Visual Studio代码不会注释掉空行 [英] Visual Studio Code Does Not Comment-out Empty Lines

查看:89
本文介绍了Visual Studio代码不会注释掉空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio代码不会注释掉空行

Visual Studio Code Does Not Comment-out Empty Lines

我到处都在寻找解决此问题的方法

I've searched everywhere for a solution to this issue but couldn't find anything, and it's been bugging me for months now.

基本上,当您告诉VS Code注释掉多行时,VS Code会忽略空行

Basically what happens is that VS Code ignores empty lines when you tell it to comment out multiple lines of code.

例如,假设我突出显示了下面的所有代码,并告诉VS Code将其注释掉:

So for example, let's say I highlighted all the code below and told VS Code to comment it out:

package com.mycompany.app;

public class MyApp {
    public static void main(String[] args) {
        SayHello();
    }

    static void SayHello() {
        System.out.println("Hello!");
    }
}

我希望得到的东西:

// package com.mycompany.app;
// 
// public class MyApp {
//     public static void main(String[] args) {
//         SayHello();
//     }
// 
//     static void SayHello() {
//         System.out.println("Hello!");
//     }
// }

我得到的是:

// package com.mycompany.app;

// public class MyApp {
//     public static void main(String[] args) {
//         SayHello();
//     }

//     static void SayHello() {
//         System.out.println("Hello!");
//     }
// }

我只有在到目前为止,Java和Golang仍然存在,但是我认为VS Code中的所有其他语言也会发生这种情况。

I've only experienced this with Java and Golang so far, but I assume this happens for all other languages inside VS Code too.

我希望我的评论保持彼此联系的原因是,我知道我一起注释掉了哪些行,以防万一我需要取消注释。

The reason I want my comments to stay connected to each other is so I know which lines I commented out together in case I need to uncomment them back.

我也知道 Shift + Alt + A 快捷方式,但通常使用块注释(我不喜欢使用),而我只需要行注释。

I am also aware of the Shift + Alt + A shortcut, but that typically uses Block Comments (which I don't like using), and I only want Line Comments.

我是否有设置?失踪了吗?因为我尝试在VS Code中搜索,但也找不到任何内容。

Is there a setting I'm missing? Because I tried searching within VS Code and couldn't find anything either.

任何帮助将不胜感激。

推荐答案

到目前为止,多行编辑似乎是唯一的替代解决方案。

Multi-line Editing seems to be the only alternative solution so far.

按住 Alt 键,然后按 Up Down ,因此光标会扩展为多行。然后只需手动添加 //

Press and hold the Alt key and press either Up or Down so your cursor expands to multiple lines. Then just add // manually.

它不是很直观,但可以。希望VS Code小组有一天会解决此问题。

It isn't very intuitive, but it works. Hopefully, the VS Code team will address this issue someday.

UPDATE: 该功能现已添加到VS Code积压! ( https://github.com/microsoft/vscode/issues/88480

这篇关于Visual Studio代码不会注释掉空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆