Tidbit
- ide|
- productivity
Quickfix in VS Code
![Guy Waldman's Profile](/_next/image?url=%2Fprofile.png&w=640&q=75)
July 18, 2024
Time to read:
2 minutes
What's your workflow for whenever those red squigglies appear in Visual Studio Code?
Do you jump over to that line, click the lightbulb (or even better, Ctrl+. or ⌘+.) and apply the suggested fix?
Do you jump over to that line, click the lightbulb (or even better, Ctrl+. or ⌘+.) and apply the suggested fix?
Well, no more!
You can create a shortcut or even a vim keybinding to apply the first quickfix suggestion.
##Shortcut
Open your keybindings configurations (open the command palette (Ctrl+Shift+P) and search for
Preferences: Open Keyboard Shortcuts (JSON)
),
and add the following entry:1{ 2 "key": "cmd+k cmd+x", // Or any other keybinding you prefer. 3 "command": "editor.action.codeAction", 4 "args": { 5 "kind": "quickfix", 6 "apply": "first" 7 } 8} 9
##Vim keybinding
Open your user settings (open the command palette (Ctrl+Shift+P) and search for
Preferences: Open User Settings (JSON)
) and add the following entry:1{ 2 "before": [ 3 "<leader>", 4 "x", 5 "x" 6 ], // Or any other keybinding you prefer. 7 "commands": [ 8 { 9 "command": "editor.action.codeAction", 10 "args": { 11 "kind": "quickfix", 12 "apply": "first" 13 } 14 } 15 ] 16} 17
NoteThe workspace settings file could also work, of course.
Doesn't have to be the user settings file.
##Extra: Jumping to the next error
To jump to the next error, you could add the following keybinding (to
keybindings.json
):1{ 2 "key": "cmd+k cmd+n", // Or any other keybinding you prefer. 3 "commands": [ 4 "editor.action.marker.nextInFiles" 5 ] 6} 7
Or for vim (
settings.json
):1{ 2 "before": ["<leader>", "n"], // Or any other keybinding you prefer. 3 "commands": ["editor.action.marker.nextInFiles"] 4} 5
##References
Related content
- productivity|
- ai
Introducing: magic-cliPostJuly 16, 2024A command line utility that will make you a magician in the terminal- technical|
- productivity
Git hooks for fun & profitPostAugust 9, 2022Using git hooks for developer workflow automation- opinion|
- productivity|
- ai
The future of software developmentPostJune 29, 2021What will the future of software tooling look like?- technical|
- productivity
Loading .env files with no dependenciesTidbitJuly 26, 2024Loading .env files easily in *NIX shells with no dependencies- devops|
- productivity
GitHub Actions step outputsTidbitJuly 12, 2024How to output data from a GitHub Actions step to reuse in a different step