VSCode snippet transform to determine the containing directory

微笑、不失礼 提交于 2020-01-04 13:59:11

问题


I've been unable to determine the transform to use to grab the directory that a new file is in from the TM_DIRECTORY that VSCode exposes?

i.e. For a path like c:\a\b\c\d\e I would like to get e as the output. I also have linux co-works so it should also work for something like /mnt/a/b/c/d/e


回答1:


Try this snippet:

"stripLastDirectory": {
    "prefix": "lsd",
    "body": [
      "${TM_DIRECTORY/.*[\\\\|\\/]+(.*)/$1/}"
    ],
},

I am unable to test that on Linux but it should work on all OS's.



来源:https://stackoverflow.com/questions/52877815/vscode-snippet-transform-to-determine-the-containing-directory

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