在Visual Studio Code中隐藏.js.map文件

本文翻译自:Hide .js.map files in Visual Studio Code

I am working on a typescript project in Visual Studio code and would like to hide the .js.map (and maybe even the .js ) files from appearing in the file explorer. 我正在Visual Studio代码中的打字稿项目上工作,并希望隐藏.js.map (甚至可能是.js )文件,以免它们出现在文件资源管理器中。

Is it possible to display only the .ts files in the file explorer? 是否可以在文件资源管理器中仅显示.ts文件?


#1楼

参考:https://stackoom.com/question/28XT3/在Visual-Studio-Code中隐藏-js-map文件


#2楼

In your settings (either user or workspace) there is a setting that you can tweak to hide anything you'd like: 在您的设置(用户或工作区)中,有一个设置可以调整以隐藏您想要的任何东西:

{
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true
    }
}

So you can add in the following to hide .js and .js.map files 因此,您可以添加以下内容以隐藏.js.js.map文件

"**/*.js": true,
"**/*.js.map": true

As this other answer explains , most people probably only want to hide .js files when there is a matching .ts file. 正如另一个答案所解释的那样 ,大多数人可能只想在存在匹配的.ts文件时隐藏.js文件。

So instead of doing: 因此,与其做:

"**/*.js": true

you might want to do: 您可能想做:

"**/*.js": {"when": "$(basename).ts"}

#3楼

I found this, If you have standard JS files then these will be hidden too which may not always be what you want. 我发现,如果您有标准的JS文件,那么这些文件也将被隐藏,而这些文件可能并不总是您想要的。 Perhaps this is better as it only hides JS files that match TS files... 也许更好,因为它只隐藏与TS文件匹配的JS文件...

{
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "**/*.js.map": true,
        "**/*.js": {"when": "$(basename).ts"}
    }
}

#4楼

I really don't know how this is implemented but for hiding .js files works: 我真的不知道这是如何实现的,但是隐藏.js文件的工作原理是:

"**/*.js": {"when": "$(basename).ts"}

For hiding .js.map files works: 用于隐藏.js.map文件的方法如下:

"**/*.js.map": {"when": "$(basename)"}

#5楼

Maybe it's better to hide .map and .js files when they match their corresponding .ts file. .map.js文件与相应的.ts文件匹配时,最好隐藏它们。
You can do that by copying the following lines in VS User Settings (Preferences > User Settings): 您可以通过在“ VS用户设置”(“首选项”>“用户设置”)中复制以下行来做到这一点:

// Workspace settings
"files.exclude": {
        "**/*.js":  {"when": "$(basename).ts"},
        "**/*.map": true
 }

#6楼

When you are working with TypeScript, you often don't want to see generated JavaScript files in the explorer or in search results. 使用TypeScript时,通常不希望在资源管理器或搜索结果中看到生成的JavaScript文件。 VS Code offers filtering capabilities with a files.exclude setting ( File > Preferences > Workspace Settings) and you can easily create an expression to hide those derived files: VS Code提供了具有files.exclude设置( 文件>首选项>工作区设置)的过滤功能,您可以轻松创建一个表达式来隐藏这些派生文件:

"**/*.js": { "when": "$(basename).ts"}

Similarly hide generated .map files by: 同样,通过以下方式隐藏生成的.map文件:

 "**/*.js.map": { "when": "$(basename)"}

So you will have a configuration like in: 因此,您将具有如下配置:

settings.json settings.json

// Place your settings in this file to overwrite default and user settings.
{
    "files.exclude": {
        "**/*.js": { "when": "$(basename).ts"},
        "**/*.js.map": { "when": "$(basename)"}
    }
}

Link: https://code.visualstudio.com/docs/languages/typescript#_hiding-derived-javascript-files 链接: https//code.visualstudio.com/docs/languages/typescript#_hiding-derived-javascript-files

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在 Visual Studio Code 配置 C 环境,请按以下步骤操作: 1. 安装 Code Runner 插件:在 Visual Studio Code 打开扩展程序面板(单击左侧的扩展图标),然后搜索 "Code Runner" 并安装该插件。 2. 安装 GCC:如果您的系统尚未安装 GCC,请先安装。在 Windows ,您可以安装 MinGW 或 TDM-GCC;在 MacOS ,您可以使用 Homebrew 安装 GCC。 3. 配置 Code Runner:打开 Visual Studio Code 的设置,单击用户设置或工作区设置,并添加以下内容: ``` "code-runner.executorMap": { "c": "gcc $fullFileName -o $fileNameWithoutExt && $fileNameWithoutExt" } ``` 4. 测试:现在,您可以在 Visual Studio Code 编写 C 代码并运行它。在编辑器打开一个 .c 文件,单击预览窗口的代码,然后选择 "Run Code" 菜单项,以运行代码并显示结果。 请注意,如果在编写代码时有语法错误,可能会在预览窗口显示错误信息,请根据提示进行修复。 ### 回答2: 配置 Visual Studio Code 的 C 环境需要以下步骤: 1. 首先,确保已安装 Visual Studio Code,并在计算机上安装了 C 编译器(比如 GCC)。 2. 打开 Visual Studio Code,并打开一个 C 文件。 3. 在 Visual Studio Code ,按下快捷键 `Ctrl + Shift + P` 或者点击菜单栏的「View」>「Command Palette...」。 4. 在命令面板输入「Tasks: Configure Task」并选择该选项。 5. 接着,在弹出的选项选择「Create tasks.json file from template」。 6. 在下拉菜单选择「Others」。 7. 然后,会生成一个 `tasks.json` 文件。打开该文件并编辑。 8. 在 `tasks.json` 文件,找到 `"command"` 字段,并将其值修改为 C 编译器的路径,比如 `"command": "gcc"`。 9. 在 `args` 数组,添加编译参数和输出参数,比如 `-o` 用来指定输出文件名。 10. 保存 `tasks.json` 文件,并回到 C 文件。 11. 在 Visual Studio Code 打开终端,按下快捷键 `Ctrl + ` `(反引号键)或点击菜单栏的「View」>「Terminal」。 12. 在终端,输入 `gcc 文件名.c -o 输出文件名` 命令来编译 C 文件,并生成可执行文件。 13. 运行生成的可执行文件,可以在终端输入 `./输出文件名` 命令。 通过以上步骤,就可以配置好 Visual Studio Code 的 C 环境,并编译运行 C 文件了。如果需要运行不同的 C 文件,只需要在 `tasks.json` 文件修改相应的参数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值