How to get the base directory in visual studio code snippet?

前端 未结 2 1312
余生分开走
余生分开走 2021-02-18 16:32

I am trying to get the file current directory in a snippet for visual studio code.

VSCode has a variable: TM_DIRECTORY, which is the fullpath

相关标签:
2条回答
  • 2021-02-18 17:25

    I wanted to add that in Windows the code above will print the entire directory.

    You need to add a quadruple backslash vs the forward-slash:

    ${TM_DIRECTORY/^.+\\\\(.*)$/$1/}
    
    0 讨论(0)
  • 2021-02-18 17:36

    Ok, finally found it.

    ${TM_DIRECTORY/^.+\\/(.*)$/$1/} gives the base directory.

    The part I didn't get was the "double escape" of the directory separator / -> \\/.

    0 讨论(0)
提交回复
热议问题