How to jump to build error in Visual Studio Code?
Solution 1
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.
Solution 2
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.
Etay Meiri
Updated on July 01, 2022Comments
-
Etay Meiri almost 2 years
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?
-
tupui over 6 yearsYou should first ask the OP with comments before posting an answer.
-
fengliutie over 6 yearsI 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!
-
tupui over 6 yearsYour 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
-
Scorb over 5 yearsIs there a way to do what you mentioned, but with a keyboard shortcut?
-
br1 almost 5 yearsEven though formulated as a question, this is the answer!
-
hsandt almost 4 yearsArg, almost works, but ctrl+click highlights the trailing ":" for me (e.g. "concepts.cpp:37:48:") so I have to type RIGHT, BACKSPACE just to remove it and go to file:line:char, which is now 3 actions...
-
ahcox almost 3 yearsThis works for me in 2021 using a vanilla install of VS Code and the MS C++ plugin, after building a simple CMake project by hitting
<F7>
with the default keybinding for that key.