14

How can I set shortcuts for it? Is it possible of using only one shortcut for toggling between two views Git Open Changes and Open file. Ideally, use only one shortcut for open changes and open file. When in the file it'll know to call open changes and vice versa, when in working tree version it'll call open file.

I'm jumping between files and its Working Tree version by command palettes: Git: Open Changes and Git: Open file

2
  • Did you find any solution? I'm either tapping command+p or using button next to "Close Window" button, it'd be great if there was a shortcut to toggle those two views. Commented May 22, 2018 at 17:14
  • 1
    @bruddha: yeah! I've found a way. Check my comment :D Commented Nov 3, 2018 at 12:25

2 Answers 2

41

I've found a way!

Open your keybindings.json (How to open)

Add these config:

... { "key": "ctrl+shift+q", "command": "git.openFile", "when": "editorFocus && isInDiffEditor" }, { "key": "ctrl+shift+q", "command": "git.openChange", "when": "editorFocus && !isInDiffEditor" } 

Now your vscode will work with ctrl+shift+q shortcut. Change to your shortcut.

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

8 Comments

anyway to close the other file? it opens both files, and focuses on the right file
I was also able to add these keyboard shortcuts by opening the Keyboard Shortcuts Menu (Preferences -> Keyboard Shortcuts), finding the relevant commands above, and changing the "when clause" by right-clicking on the relevant row and clicking "Change When Expression" to match the clauses above.
@azizj1 git.openChange not git.OpenChange
That link to "Open your keybindings.json" goes to another answer to this question which tells you how to open the Keyboard Shortcuts UI, not the keybindings.json file.
For those who are not working: The order matters, openFile should precede openChange.
|
1

You can set a shortcut for any command.

File > Preferences > Keyboard Shortcuts or (Mac) Code > Preferences > Keyboard Shortcuts

Type the command you want to set a shortcut for to quickly bring it to the top and click the "+" button at the far left of the column and set the shortcut.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.