简体   繁体   English

VScode 终端中不需要的输出

[英]Unwanted output in the terminal of VScode

I love visual studio code .我喜欢视觉工作室代码。 But the main problem is when i run a program, i get some unwanted output in the terminal但主要问题是当我运行程序时,我在终端中得到了一些不需要的输出

I attached an image, where the unwanted output is wrapped in red line.Is there any way to get rid of this unwanted output in the terminal ?我附上了一张图片,不需要的输出用红线包裹。有什么办法可以摆脱终端中不需要的输出? 在此处输入图像描述

It worked for me:它对我有用:

  • Open Visual Studio Code and press F1 to open the command panel打开 Visual Studio Code 并按F1打开命令面板
  • Search for Preferences: Open Settings (JSON) and open it.搜索首选项:打开设置(JSON)并打开它。 It will open a settings.json file它将打开一个settings.json文件
  • You should see something like this你应该看到这样的东西
{
    "editor.fontSize": 17,
    "code-runner.runInTerminal": true,
    "terminal.integrated.defaultProfile.windows": "PowerShell"
}
  • Paste the code below, above "terminal.integrated.defaultProfile.windows": "PowerShell"将下面的代码粘贴到"terminal.integrated.defaultProfile.windows": "PowerShell"
"terminal.integrated.profiles.windows": 
{
    "PowerShell": 
    {
        "source": "PowerShell",
        "args": ["-noLogo"]
    }
},
  • After this, the settings.json should be something like this在此之后, settings.json应该是这样的
{
    "editor.fontSize": 17,
    "code-runner.runInTerminal": true,
    "terminal.integrated.profiles.windows": 
    {
        "PowerShell": 
        {
            "source": "PowerShell",
            "args": ["-noLogo"]
        }
    },
    "terminal.integrated.defaultProfile.windows": "PowerShell"
}
  • Hit Ctrl + S to save and close settings.json按 Ctrl + S保存并关闭settings.json

在此处输入图像描述

  1. Install code runner extension安装代码运行器扩展

  2. Go to Code Runner extensions settings转到 Code Runner 扩展设置

Search for Executor Map and then click Edit in settings.json Depending on the programing language that you use add the following instead of default one:搜索 Executor Map,然后单击 settings.json 中的 Edit 根据您使用的编程语言添加以下内容而不是默认语言:

"c": "cls && function prompt{">>"} && $Host.ui.rawui.foregroundcolor = "cyan" && cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && echo `n && $Host.ui.rawui.foregroundcolor = "red"", "c": "cls && 函数提示符{">>"} && $Host.ui.rawui.foregroundcolor = "cyan" && cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && echo `n && $Host.ui.rawui.foregroundcolor = "红色"",

In case you use C++ then just change "c": to "cpp": and be aware to to replace gcc to g++ or to clang++ in case you use clang如果您使用 C++,那么只需将 "c": 更改为 "cpp": 并注意将 gcc 替换为 g++ 或 clang++,以防你使用 clang

you can check my videos for detailed explanation您可以查看我的视频以获取详细说明

quick: https://youtu.be/yq8j3AsEOL0快速: https ://youtu.be/yq8j3AsEOL0

Detailed: https://youtu.be/WM5iW8SyGpk详解: https ://youtu.be/WM5iW8SyGpk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM