5

I'm using VS Code with a number of different programming languages, which all have some form of problem validation provided via an extension. While these problem underlines are generally useful, I find them very annoying while I'm writing a particular piece of code, and only useful once I'm mostly done typing. I often think while writing code and I also tend to hit Ctrl+S very often, so there is no way that my IDE can "debounce" properly, as it wouldn't be able to tell if I'm done writing code or not.

How can I disable all lints from being displayed, regardless of the programming language used, until I re-enable them (or restart Code or whatever)?

I'm not looking for a always-hidden solution that permanently changes my settings. More for something that I can toggle with a keyboard shortcut or similar.

While I am most interested in a solution that works regardless of where the lints come from, the two extensions that'd be responsible for most of my lints are rust-analyzer and Kotlin, but I also have clangd and TexLab installed and also use TypeScript whenever I can't avoid it but currently I don't have any extension for it installed.

starball
  • 20,030
  • 7
  • 43
  • 238
msrd0
  • 7,816
  • 9
  • 47
  • 82
  • https://learn.coderslang.com/0023-eslint-disable-for-specific-lines-files-and-folders/ , You can try reding this article maybe it helps you – kuuhak-u Dec 10 '22 at 13:13
  • 1
    @kuuhak-u Thanks but I'm not interested in a programming-language specific solution (also I barely use typescript at all) – msrd0 Dec 10 '22 at 13:15
  • Related (if you want to debounce/delay instead of disable/toggle): [In Visual Studio Code, is it possible to delay displaying inline errors when editing C# code, perhaps until I save the file?](/q/64719791). – starball Feb 17 '23 at 21:21

4 Answers4

4

I don't think the exact thing you are looking for exists at the time of this writing.

I am not aware of any "global" (programming-language-agnostic) setting that toggles showing underlines for problems in the editor view. There is a setting that toggles showing decorations for problems in the Explorer view (problems.decorations.enabled), but that's not what you're looking for.

As shown by the answers to How to disable error highlighting in VS Code?, there are settings on a per-language basis to disable validation (such as css.validate, php.validate.enable, html.validate.*, json.validate.enable, java.validate.enable, etc. Note that language extensions may not follow that pattern of naming their settings fields, such as C_Cpp.errorSquiggles and python.linting.enabled)

In terms of getting a keyboard shortcut to toggle such a setting (whether the currently-non-existent-(I-think) programming-language-agnostic setting, or an individual programming-language-specific setting), see this Q&A: VSCode: Keyboard shortcuts for modifying user settings, where @matt-bierner points to the rebornix.toggle extension, which allows configuring keyboard shortcuts to toggle individual bi-state settings fields (I have no affiliation with this extension).

As for feature-requests and possible future features to VS Code, see this issue on the VS Code GitHub repo: Toggle problem visibility in Editor #166797. You can show your support for the issue ticket by giving a thumbs up reaction to the issue. But please don't make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don't contribute anything of significant value.

You can at least hide the squiggly error underline by putting the following in your settings.json file, but know that it won't actually prevent the problems from being recognized (you can wrap):

"workbench.colorCustomizations": {
    "editorError.foreground": "#0000",
    "editorError.background": "#0000",
    "editorError.border": "#0000",
    "editorWarning.foreground": "#0000",
    "editorWarning.background": "#0000",
    "editorWarning.border": "#0000",
    "editorHint.foreground": "#0000",
    "editorHint.background": "#0000",
    "editorHint.border": "#0000",
}
starball
  • 20,030
  • 7
  • 43
  • 238
2

Override theme colors in settings.json

{
  "workbench.colorCustomizations": {
    "[Visual Studio Light]": {
      "editorError.foreground": "#00000000"
    },
    "editorError.foreground": "#00ff00"
  }
}

will make errors transparent while using "Visual Studio Light" theme
and lightgreen while using any other theme, for example

Source: https://youtu.be/vR2y4VoCZg4?t=97

Dimava
  • 7,654
  • 1
  • 9
  • 24
  • Writing something in my `settings.json` isn't exactly what I thought when I meant "toggling" (temporarily hiding) linting on/off as I wish. I'd prefer something more keyboard-shortcut-alike. – msrd0 Dec 27 '22 at 20:58
  • You can change the colors for a specific theme, meaning you can easily toggle that by toggling a theme – Dimava Dec 27 '22 at 20:59
  • @msrd0 here, an example for a single theme. Theme toggle is `Ctrl+K Ctrl+T` iirc – Dimava Dec 27 '22 at 21:05
  • Does this define a new theme that has all the other colors the same but the error highlight color changed? – msrd0 Dec 27 '22 at 21:06
  • No, this takes an existing theme (it has autocompletion, so it'll say what you have), and overrides its features. Just try it with whatever theme that looks almost the same to the one you currently use – Dimava Dec 27 '22 at 21:14
  • Like, I use default `Light+` and the one I've changed is default `Light` theme – Dimava Dec 27 '22 at 21:16
  • While this is a neat trick, it misses out on the "_easily toggle_" requirement of the question. But there are extensions that enable binding keyboard commands to toggle settings. I'm not sure how applicable those are here since this is not a boolean-valued setting. – starball Feb 22 '23 at 18:36
2

with the extension When File you can make the squiggles transparent when the file is dirty.

Add this to your settings.json file (global or workspace/folder)

"whenFile.change": {
  "whenDirty": {
    "editorError.foreground": "#ff000020",
    "editorWarning.foreground": "#ff000020",
    "editorInfo.foreground": "#ff000020"
  }
}
rioV8
  • 24,506
  • 3
  • 32
  • 49
-4

File add a new line css. Lint dot empty rules and assign the value of ignore.

  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 01 '23 at 21:46