Home > Software design >  using regex inside keybindings.json
using regex inside keybindings.json

Time:11-22

I want to use regex inside of the text in args,

{
    "key": "ctrl shift r",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text":'${file}.'\u000D"  } 
}

I want to take the name of the file from the file path using this regex - ^\\(. \\)*(. )\.(. )$ or taking the filename in other way, anyone can help?:)

CodePudding user response:

You do not need to use a regexp, you want to use a different variable:

{
  "key": "ctrl shift r",
  "command": "workbench.action.terminal.sendSequence",
  "args": { "text": "'${fileBasename}'"  } 
}

See Variables Reference.

  • Related