Josh R
Josh R

Reputation: 2210

How to jump to file explorer in VS Code?

Using the VIM extension for VS Code is there a key command to jump to the explorer pane and then back to the work window?

I cannot find anything in the docs.

I'm hoping there is something like my Control+N binding for NERDTree which lets me open the file viewer, pick a file and then close it.

Upvotes: 32

Views: 36913

Answers (6)

JoePerkins
JoePerkins

Reputation: 975

If you want to find the file faster by typing the file name and you don't want to lose your Vim normal Ctrl+P functionality, you could add this to your settings.json to map the VSCode Quick Open action to leader + p.

  "vim.normalModeKeyBindings": [
    {
        "before": ["<leader>", "p"],
        "commands": ["workbench.action.quickOpen"]
    },

Upvotes: 1

CamelBlues
CamelBlues

Reputation: 3764

Also if you are using the vim extension for VS code you can edit settings.json with :

    "vim.handleKeys": {
        "<C-p>": false,
    }
}

to bring back the native VSCode file search with Ctrl+p

Upvotes: 16

Santiago
Santiago

Reputation: 714

I am not familiar with NERDTree, but I think Ctrl+Shift+e does what you are asking in vs code. Alternatively Ctrl+p may be an alternative? You could look at linux keyboard shortcut for more reference.

The link is also available in Help > Keyboard Shortcut Reference

EDIT: I'm adding the equivalent shortcut for Mac OS since it's different layout. However, I don't use Mac OS.. So I add this without being able to confirm :

Shift+Command+E Mac OS Keyboard shortcut for VS Code

Windows keyboard shortcuts are very similar to linux ones. So, I'll just include the link to windows shortcuts doc here. Windows Keyboard shortcut for VS Code

Upvotes: 36

Aindri&#250;
Aindri&#250;

Reputation: 3730

If you want to go to a file with VIM in VSCode:

Enter Normal Mode (Esc)

Place cursor over file you want to jump to, e.g. between the quotes - "../models/postMessage.js";

Press lowercase gd - Go to definition

Upvotes: 1

taavs
taavs

Reputation: 709

Just my two cents:

If you are using the Vim extension for VS code you can add this to your settings.json file:

"vim.normalModeKeyBindings": [
  {
    "before" : ["<leader>","a"],
    "commands" : [
      "workbench.view.explorer"
    ]
  }
]

The exemple above uses <leader> + a while in normal mode to display the file explorer where you can navigate the file list with j and k. Pressing ENTER will open the file under the cursor and close the file list.

To set up a leader key just add in your settings.json:

"vim.leader" : "," ,

Upvotes: 20

dkim
dkim

Reputation: 41

In addition to Santiago's comment, you're able to open a file in a new tab from the explorer (Cmd + Shift + E) with Ctrl + Enter for MacOS. I'm not sure about Windows or Linux.

Upvotes: 4

Related Questions