-
Notifications
You must be signed in to change notification settings - Fork 60
Sidebar and file explorer keys and menu
Tom Short edited this page Nov 7, 2021
·
5 revisions
Here are some key definitions and a menu to aid with keyboard navigation on the sidebar. Specifically for the file-explorer sidebar, custom keystrokes and a menu are included.
Here are key definitions. Many are adapted from VSCodeVim from here. The general when
: listFocus
entries are movement keys (h, j, k, l, ...). The when
: explorerViewletVisible
entries are specific to the file explorer. These can be used for file operations like copy, paste, delete, and so on. The ,
or m
keys launch a menu for these file operations.
{
"key": "h",
"command": "list.collapse",
"when": "listFocus && !inputFocus"
},
{
"key": "j",
"command": "list.focusDown",
"when": "listFocus && !inputFocus"
},
{
"key": "k",
"command": "list.focusUp",
"when": "listFocus && !inputFocus"
},
{
"key": "l",
"command": "list.select",
"when": "listFocus && !inputFocus"
},
{
"key": "o",
"command": "explorer.openWith",
"when": "listFocus && !inputFocus"
},
{
"key": "r",
"command": "revealFileInOS",
"when": "listFocus && !inputFocus"
},
{
"key": "f",
"command": "copyFilePath",
"when": "listFocus && !inputFocus"
},
{
"key": "s",
"command": "list.toggleSelection",
"when": "listFocus && !inputFocus"
},
{
"key": "shift+f",
"command": "copyRelativeFilePath",
"when": "listFocus && !inputFocus"
},
{
"key": "n",
"command": "explorer.newFile",
"when": "listFocus && !inputFocus"
},
{
"key": "shift+n",
"command": "explorer.newFolder",
"when": "listFocus && !inputFocus"
},
{
"key": "ctrl+d",
"command": "list.focusPageDown",
"when": "listFocus && !inputFocus"
},
{
"key": "ctrl+u",
"command": "list.focusPageUp",
"when": "listFocus && !inputFocus"
},
{
"key": "escape",
"command": "workbench.action.toggleSidebarVisibility",
"when": "sideBarFocus && !inputFocus && !HasSelectionOrFocus"
},
{
"key": "escape",
"command": "list.clear",
"when": "listFocus && listHasSelectionOrFocus && !inputFocus"
},
{
"key": "g g",
"command": "list.focusFirst",
"when": "listFocus && !inputFocus"
},
{
"key": "g k",
"command": "list.focusFirst",
"when": "listFocus && !inputFocus"
},
{
"key": "g j",
"command": "list.focusLast",
"when": "listFocus && !inputFocus"
},
{
"key": "g h",
"command": "list.focusLast",
"when": "listFocus && !inputFocus"
},
{
"key": "/",
"command": "list.toggleKeyboardNavigation",
"when": "listFocus && listSupportsKeyboardNavigation"
},
{
"key": "y",
"command": "filesExplorer.copy",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
},
{
"key": "x",
"command": "filesExplorer.cut",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
},
{
"key": "p",
"command": "filesExplorer.paste",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
},
{
"key": "d",
"command": "moveFileToTrash",
"when": "explorerResourceMoveableToTrash && explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
},
{
"key": "c",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "shift+o",
"command": "explorer.openAndPassFocus",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
},
{
"key": "v",
"command": "filesExplorer.openFilePreserveFocus",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
},
{
"key": ",",
"command": "dance.openMenu",
"args": { "input": "file-explorer" },
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "m",
"command": "dance.openMenu",
"args": { "input": "file-explorer" },
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
For these keybindings to work right, you need the following in settings.json
:
"workbench.list.automaticKeyboardNavigation": false,
Here is a Dance menu for use in the file explorer sidebar (defined in settings.json
):
"file-explorer": {
"items": {
"y": { "text": "Yank file", "command": "filesExplorer.copy" },
"p": { "text": "Paste file", "command": "filesExplorer.paste" },
"c": { "text": "Rename file", "command": "renameFile" },
"d": { "text": "Delete file", "command": "moveFileToTrash" },
"x": { "text": "Cut file", "command": "filesExplorer.cut" },
"r": { "text": "Reveal in file explorer", "command": "revealFileInOS" },
"o": { "text": "Open with...", "command": "explorer.openWith" },
"O": { "text": "Open", "command": "explorer.openAndPassFocus" },
"v": { "text": "View", "command": "filesExplorer.openFilePreserveFocus" },
"f": { "text": "Copy file path", "command": "copyFilePath" },
"F": { "text": "Copy relative file path", "command": "copyRelativeFilePath" },
"n": { "text": "New folder", "command": "explorer.newFile" },
"N": { "text": "New file", "command": "explorer.newFolder" },
}
},