17

I'm using Visual Studio Code (Version 1.8.1) on Linux. When there is a build error and I click on the line that contains the error it doesn't jump to the corresponding line in the code. Is there a way to make Visual Studio Code behave the same as standard Visual Studio?

2
  • 1
    Not an answer to the question, but alt-F8 will quickly take you to the next error, at least it does for TypeScript. Commented Apr 9, 2019 at 15:33
  • alt-f8 ?? it seem to do something, but 1) alt-f8 is not a keystoke that allows anything 'quickly', since I cant press that left-handed 2) it seems to cycle through 3 of to 6 problems in my case, not sure why Commented Jan 6, 2020 at 8:28

4 Answers 4

11

Have you defined a problem matcher in your tasks.json? There are several built-in ones that can simply be referenced, for instance "problemMatcher": ["$tsc"] will work for TypeScript.

The docs also contain an example for a custom problem matcher for C++:

"problemMatcher": {
    "owner": "cpp",
    "fileLocation": ["relative", "${workspaceRoot}"],
    "pattern": {
        "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
        "file": 1,
        "line": 2,
        "column": 3,
        "severity": 4,
        "message": 5
    }
}

If there's no built-in matcher for the language you're using, you shoulds still be able to find one with a bit of searching if it's moderately popular.

Sign up to request clarification or add additional context in comments.

Comments

7

Did you build your code in TERMINAL window of Visual Studio Code? If so, press down the "Ctrl" key and move the mouse cursor to the filename and line number such as "/home/..../xxx.cpp:123" in the error line, then you can click on it to jump to the corresponding line in the code

It works for me.

8 Comments

You should first ask the OP with comments before posting an answer.
I didn't know it's better to ask the OP before posting an answer. It was my first time posting an answer. Thank you for reminding me!
Your welcome. Indeed, your should be certain when you write an answer, otherwise comments are a great place for that. Here is a recap How to Answer
Is there a way to do what you mentioned, but with a keyboard shortcut?
Even though formulated as a question, this is the answer!
|
2

You can quickly jump to the error in your code by using the shortcut of Ctrl + shift + M

1 Comment

FYI, Ctrl-M disables tab (yes, the tab key) and the problems list is ordered by filename, so it's not always the first error
1

Using a vanilla install of Visual Studio Code and the Microsoft C++ plugin, after building a simple CMake project by hitting <F7> with the default keybinding for that key, <CTRL-LEFT_MOUSE> works great to navigate to the line of an error from the TERMINAL tab. Note the errors in the OUTPUT window are not clickable.

Errors in this tab are clickable: Terminal tab

Errors in this tab are not clickable: enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.