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

江枫思渺然 提交于 2021-01-27 05:16:10

问题


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?


回答1:


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 )



来源:https://stackoverflow.com/questions/48203523/how-to-create-file-in-current-explorer-directory-in-vs-code-using-only-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!