Out of the box Visual Studio Code is great but doesn’t do save+compile+debug very well. The default debugging configuration just runs the debugger on existing code without saving or compiling first.
But the task system is GREAT and makes almost any possible automation pretty straightforward. Here’s a quick example. First set up any command line tasks you might need in your tasks.json file (Terminal > Configure Tasks > pick any task), eg:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello",
"group": "build"
},
{
"label": "Build cmake-debug",
"type": "shell",
"command": "clear && bash -i -c 'at dbd'",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build cmake-release",
"type": "shell",
"command": "clear && bash -i -c 'at dbr'",
"group": "build",
"problemMatcher": [
"$msCompile"
]
},
{
"label": "cmake",
"type": "shell",
"command": "clear && bash -i -c 'at dba'",
"group": "build",
"problemMatcher": [
"$gcc"
]
},
{
"label": "Go",
"dependsOn": [
"Build cmake-debug"
],
"problemMatcher": [
"$gcc"
]
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/cmake-debug/at_server",
"args": ["localhost","8000","localhost","etc"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Go"
}
]
}
Some other things of note.
- Performance of these automatic checks currently SUCKS and you need to turn them off:
"npm.autoDetect": "off",
"gulp.autoDetect": "off",
"grunt.autoDetect": "off",
"jake.autoDetect": "off",
"typescript.tsc.autoDetect": "off",
- Bookmarks are essential, and I found that I like to have both of these popular extensions installed:
- Bookmarks; go F2, set ctrl-F2
- Numbered bookmarks; go c-1, set c-a-sh-1
- There are lots more cool extensions, but be careful about bloat. Add, try, remove if not necessary.