DEV Community

Krzysztof Platis
Krzysztof Platis

Posted on

Boost Your Code Review Game with Custom VSCode Shortcuts ⌨️

If you're a tech lead who spends a lot of time reviewing code and helping others, you know how crucial it is to be efficient. Over time, I've set up some handy keyboard shortcuts in Visual Studio Code (VSCode) that make my life a whole lot easier. Let me show you my keybindings.json and how these shortcuts can help you too.

Switch Between Diff and Source

Switching between the diff view and the source view can be such a hassle, especially during code reviews.

These shortcuts make it super easy:

// Toggle between file diff and file source when in a diff editor
{
  "key": "cmd+ctrl+f",
  "command": "git.openFile",
  "when": "editorFocus && isInDiffEditor"
},
// Toggle between file source and file diff when not in a diff editor
{
  "key": "cmd+ctrl+f",
  "command": "git.openChange",
  "when": "editorFocus && !isInDiffEditor"
}
Enter fullscreen mode Exit fullscreen mode

How to Use: Just hit cmd+ctrl+f to switch between the diff and source views, no matter where you are. It feels like magic!

Quick GitHub Links

I share specific lines of our codebase from GitHub all the time. These shortcuts make copying and opening GitHub permalinks a breeze:

// Copy GitHub permalink
{
  "key": "shift+cmd+c",
  "command": "issue.copyGithubPermalink"
},
// Open GitHub permalink
{
  "key": "shift+cmd+x",
  "command": "issue.openGithubPermalink"
}
Enter fullscreen mode Exit fullscreen mode

How to Use: Press shift+cmd+c to copy a permalink to your clipboard and shift+cmd+x to open a permalink right in your browser. So simple and fast!

See Tree of All Changed Files

During code reviews, I often need to switch between the tree of changed files and the tree of all files in the repo. This shortcut makes that transition seamless:

// Focus on the active pull request
{
  "key": "shift+cmd+l",
  "command": "github:activePullRequest.focus"
}
Enter fullscreen mode Exit fullscreen mode

How to Use: With the official GitHub Pull Request extension installed, press shift+cmd+l to quickly focus on the active pull request. This keeps your workflow smooth and uninterrupted. When you need to switch to a tree of all files in the project, you can use the default shortcut shift+cmd+e.

Navigate Changes in File

When you're deep into a code review, navigating through changes efficiently is key. These shortcuts help you jump between changes within a single file effortlessly, without needing to manually scroll to the next change:

// Go to the next change in the compare editor
{
  "key": "ctrl+shift+down",
  "command": "workbench.action.compareEditor.nextChange",
  "when": "textCompareEditorVisible"
},
// Go to the previous change in the compare editor
{
  "key": "ctrl+shift+up",
  "command": "workbench.action.compareEditor.previousChange",
  "when": "textCompareEditorVisible"
},
Enter fullscreen mode Exit fullscreen mode

How to Use: Use ctrl+shift+down to jump to the next change and ctrl+shift+up to go back to the previous change in the compare editor. This makes navigating through changes in your code reviews quick and efficient.

Wrapping Up

These custom VSCode shortcuts have saved me tons of time and made my work a lot smoother. Whether you’re reviewing code, sharing GitHub links or switching between diff and source file of your own changes, these shortcuts can seriously up your game. Give them a try and see how much easier your workflow can get!

Top comments (0)