2

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

8
  • How are you trying to improve your vim skills, if you use vscode? I thought I need to use vim to improve vim skills. Commented Jul 15, 2021 at 11:26
  • I love using vim while programming, It is easy for me to navigate through my code and edit. It has many helpful functions that I cannot get in other editors and it is customizable. So, that's why I want to learn more about navigating through file trees. Commented Jul 15, 2021 at 11:37
  • I am confused. You say, you use VS Code. How is it connected to vim? Commented Jul 15, 2021 at 11:42
  • 1
    VScode / View / Command Palette.. is an essential entry. You can learn the editor features by typing Help: Welcome and find Learn section which helps solve most of your concerns. Commented Jul 15, 2021 at 11:53
  • 1
    @DracoAter There is a vim extension for vscode that is like an emulator and you have the same keybinds etc Commented Jul 15, 2021 at 13:47

2 Answers 2

2

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.

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

2 Comments

This is not entirely correct. The vim extension allows you to disable specific shortcuts. They will be handled by VSCode instead.
This is actually incorrect. VSCodeVim provides settings like vim.handleKeys and vim.useCtrlKeys to control that behavior.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.