0

I'm trying to move from sublime to vscode, and can't get how to move some of my keybindigs. One of them is "=" which inserts <?=$1?> when I'm editing html code in php files. What is more in sublime I've configure it to match some preceding text so it doesn't insert for "=" after attributes <img src=""/> will be tipped as it is. In sublime it was configured as

{ "keys": ["="], "command": "run_macro_file", "args": {"file": "res://Packages/User/macro/php/quick_echo_php.sublime-macro"}, "context":[
    {"key": "selector", "operator": "equal", "operand": "embedding.php", "match_all":true},
    {"key": "selector", "operator": "not_equal", "operand": "meta.embedded.line.php", "match_all":true},
    {"key": "selector", "operator": "not_equal", "operand": "source.php", "match_all":true},
    {"key": "selector", "operator": "not_equal", "operand": "source.js.embedded.html", "match_all":true},
    {"key": "selector", "operator": "not_equal", "operand": "punctuation.definition.tag.end.html", "match_all":true},
    {"key": "preceding_text", "operator": "not_regex_match", "operand": ".*<"},
    {"key": "preceding_text", "operator": "not_regex_match", "operand": ".*\\?"},
    {"key": "preceding_text", "operator": "not_regex_match", "operand": ".*[a-zA-Zа-яА-Я]+"},
    {"key": "setting.command_mode", "operand": false}
]},

In vscode all I end with is

{
    "key": "=",
    "command": "editor.action.insertSnippet",
    "args": {"snippet": "<?=$1?>"},
    "when": "vim.active && !inDebugRepl && vim.mode == Insert && editorLangId =~ /php|html/"
},

and obvious it is useless cause "=" is really necessary symbol in all php for example $a = 1;

I didn't find anything useful in "Developer: Inspect Context Keys". I even tried to ctrl+f "html" in vscode dev console after focused html line in php file and saw zero matches there. I just can't find scope for keybindigs but it exists for snippets.

P.S "langId" in "args" doesn't help ether.

  • 1
    Look at the HyperSnips extension. – Mark Aug 18 '21 at 21:41
  • It will solve preceding text with regex, but still no scope. I can try to findout scope by myself with regex but it is wasting of resource cause vscode usually know scope. UPDATE: it actually have some function for scope, but pure php, and html in php both gives me same ```["source.php", "constant.other.php"]``` array. Sad cause it looks like it can solve it. – Матвей Кучеров Aug 18 '21 at 22:54

0 Answers0