如何隐藏或折叠 VSC 中的所有 javascript console.log 行 [英] How to hide or collapse all javascript console.log lines in VSC

查看:19
本文介绍了如何隐藏或折叠 VSC 中的所有 javascript console.log 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大量的日志记录对我很有帮助.

然而,有时我想通过隐藏、折叠或降低console.log字体的不透明度来暂时减少我在VSC中编辑的代码的混乱javascript、Vue、React 等中的 console.warnconsole.error

我怎样才能实现我的目标?

如果有什么方法可以轻松地打开/关闭该功能,我会很高兴.

解决方案

非常感谢@rioV8,他为我指出了答案.

这似乎对我有用当使用扩展

Lots of logging is very helpful to me.

However, sometimes I would like to temporarily reduce the clutter of code that I'm editing in VSC by hiding, collapsing, or reducing the opacity of the font of console.log, console.warn, and console.error lines in javascript, Vue, React, etc.

How could I accomplish my goal?

I'd love if there were some way to easily toggle the feature on/off.

解决方案

Thank you so much to @rioV8, who pointed me to the answer.

This seems to work for me when using extension Highlight:

"highlight.regexes": {
    "(console\\.(log|warn|error)\\(.+\\)[;]?)": {
        "regexFlags": "g",
        "decorations": [
          { "opacity": "0.1" }
        ]
      }
}

To determine what regular expression I wanted to use, I wrote these test cases in https://www.regexpal.com:

console.log('asdfdsf')
console.log({some})
console.log({some});
console.error('error', msg);
console.warn('careful', thing)

And (console\.(log|warn|error)\(.+\)[;]?) worked. Then I needed to add an extra \ before each \ to satisfy the VSC settings JSON file.

Now my VSC looks like this:

这篇关于如何隐藏或折叠 VSC 中的所有 javascript console.log 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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