Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - Shortcut for toggling Git Open Changes and Git Open File

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

like image 730
qmn1711 Avatar asked Jun 24 '17 14:06

qmn1711


2 Answers

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.

like image 173
qmn1711 Avatar answered Oct 30 '22 05:10

qmn1711


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.

like image 40
kimcodes Avatar answered Oct 30 '22 07:10

kimcodes