Egidius
Egidius

Reputation: 1459

How to navigate through file tree in VS Code using vscodevim?

I am trying to improve my skill with using the vim extension on vscode, and I would like to ask if it is possible to navigate through the file tree with it.

Here is what I would want to do:

  1. Jump from my window to file tree.
  2. Move up/down
  3. Open a specific file (eg. search index.jsx and open it)
  4. Delete a file
  5. Add a new file/folder in the tree
  6. Open a file that has a specific class/function

If there is a better document for this, I would be glad to explore more :)

enter image description here

Upvotes: 2

Views: 6261

Answers (2)

ofthelit
ofthelit

Reputation: 1491

1. Jump from my window to file tree.

Add into the Visual Studio Code settings.json some of the following configuration:

{
  "vim.leader": "<space>",
  "vim.normalModeKeyBindings": [
    {
      "before": ["<leader>", "p"],
      "commands": ["workbench.view.explorer"]
    },
    {
      "before": ["<leader>", "P"],
      "commands": ["workbench.files.action.showActiveFileInExplorer"]
    }
  ],

  "vim.handleKeys": {
    "<C-p>": false,
    "<C-c>": false,
    "<C-v>": false,
    "<C-x>": false,
    "<C-a>": false,
    "<C-w>": false,
    "<C-y>": false,
    "<C-f>": false
  },
  "vim.useSystemClipboard": true,
}

2. Move up/down

Use the vim navigation keys: L or Enter will open the file.

3. Open a specific file (eg. search index.jsx and open it)

I suggest to use the built-in Ctrl+P feature from Visual Studio Code.

4. Delete a file

Use the delete key on your keyboard.

5. Add a new file/folder in the tree

Edit the VS Code keybindings.json or set your own in the vim config.

6. Open a file that has a specific class/function

Check out the documentation.

Upvotes: 0

Vlad Mikheenko
Vlad Mikheenko

Reputation: 220

VSCodeVim provides only text editing and navigation commands like }, dd, p and so on. Moreover, None of the native Visual Studio Code ctrl (e.g. ctrl+f, ctrl+v) commands work. The only way to use VSCode commands is turn off vim extension: ctrl + P > Toggle Vim Mode.

Upvotes: 2

Related Questions