Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create file in current explorer directory in vs code using only keys?

Like in vim nerd tree plugin, when you push 'm' then 'a' button in vim nerd tree you can add file in current directory where cursor on Nerd tree. Is it possible do it in vs code? Maybe some plugins?

like image 494
vkhv Avatar asked Jan 11 '18 09:01

vkhv


People also ask

How do I use File Explorer VS Code?

Explorer. The Explorer is used to browse, open, and manage all of the files and folders in your project. VS Code is file and folder based - you can get started immediately by opening a file or folder in VS Code. After opening a folder in VS Code, the contents of the folder are shown in the Explorer.


1 Answers

Unfortunately there is no such plugin yet but you could define some customized keybindings which resembles NERDTree to some extent ( File > Preferences > Keyboard Shortcuts and click on the link keybindings.json ):

[
  {
    "key": "f",
    "command": "explorer.newFile",
    "when": "explorerViewletFocus && !inputFocus"
  },
  {
    "key": "d",
    "command": "explorer.newFolder",
    "when": "explorerViewletFocus && !inputFocus"
  },
  {
    "key": "x",
    "command": "deleteFile",
    "when": "explorerViewletFocus && !inputFocus"
  },
  {
    "key": "r",
    "command": "renameFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },
  {
    "key": "enter",
    "command": "list.select",
    "when": "listFocus && !inputFocus"
  },
  {
    "key": "o",
    "command": "list.select",
    "when": "listFocus && !inputFocus"
  }
]

You could change the keys freely and commands are self explanatory. i. e: hitting f in explorer will add a file in selected directory and ... ).

Fortunately we also have j and k movements in explorer via vscodevim plugin.

The only missing part is searching the tree; and of course there is a promise to be added by January 2019 ( see issue #10026 )

like image 96
dNitro Avatar answered Oct 06 '22 01:10

dNitro