skip to Main Content

In VS Code, the F8 keyboard shortcut takes you to the next ‘problem’. Problems can be errors, warnings, or info. I want to cycle through only the errors using a keyboard shortcut. Is this possible?

2

Answers


  1. It’s currently not possible- at least- not in vanilla VS Code without a dedicated extension that does it.

    See this feature-request issue ticket on the VS Code GitHub repo opened by torkelrogstad: Go to next error/warning/info #105795. Quoting from the issue ticket:

    I’d love a feature where I could go to the next error in the file I’m in, or in the entire project, but not the next warning/info marker. Currently I have these shortcuts available:

    • editor.action.marker.next
    • editor.action.marker.nextInFiles
    • editor.action.marker.prev
    • editor.action.marker.prevInFiles

    I think it’d make a lot of sense to expose similar shortcuts for going to the next error, or the next warning, or the next info, but as separate groups.

    Example use case: I have a spell checker and a linter enabled for my project. The linter produces both warnings and errors, and the spell checker produces info markers. I care mostly about linter errors and compiler errors, and when those are fixed I care about spelling errors.

    It’s currently not implemented. 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.

    As Mark showed in their answer, in the discussion thread of the issue ticket I linked, there is the yy0931.go-to-next-error extension that can be used for this.

    Login or Signup to reply.
  2. The github issue provided by @user has a link to an extension, Go To Next Error, which looks promising in my testing. You can make a keybinding like this (in your keybindings.json):

    {
      "key": "alt+8",            // whatever keybinding you want
      "command": "go-to-next-error.nextInFiles.error",
      "when": "editorFocus"
    }
    

    or if you want to override the existing F8 try these:

    {
      "key": "F8",
      "command": "-editor.action.marker.nextInFiles",
      "when": "editorFocus"
    },
    {
      "key": "F8",
      "command": "go-to-next-error.nextInFiles.error",
      "when": "editorFocus"
    }
    

    That uses the across files command: go-to-next-error.nextInFiles.error. The go-to-next-error.next.error command would not jump to other files.

    Available commands are

    go-to-next-error.nextInFiles.error      Go to Next Problem in Files (Error)     
    go-to-next-error.next.error             Go to Next Problem (Error)      
    go-to-next-error.nextInFiles.warning    Go to Next Problem in Files (Error, Warning)        
    go-to-next-error.next.warning           Go to Next Problem (Error, Warning)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search