Я использую следующие сочетания клавиш, чтобы быстро заключить выделенный текст в фигурные скобки:
{"key": "shift+9", "command": "editor.action.insertSnippet", "args": {"snippet": "$0($TM_SELECTED_TEXT)" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "shift+0", "command": "editor.action.insertSnippet", "args": {"snippet": "($TM_SELECTED_TEXT)$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+[", "command": "editor.action.insertSnippet", "args": {"snippet": "$0{$TM_SELECTED_TEXT}" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+]", "command": "editor.action.insertSnippet", "args": {"snippet": "{$TM_SELECTED_TEXT}$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "[" , "command": "editor.action.insertSnippet", "args": {"snippet": "$0[$TM_SELECTED_TEXT]" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "]" , "command": "editor.action.insertSnippet", "args": {"snippet": "[$TM_SELECTED_TEXT]$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "shift+,", "command": "editor.action.insertSnippet", "args": {"snippet": "$0<$TM_SELECTED_TEXT>" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "shift+.", "command": "editor.action.insertSnippet", "args": {"snippet": "<$TM_SELECTED_TEXT>$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+9", "command": "editor.action.insertSnippet", "args": {"snippet": "$0(\n\t$TM_SELECTED_TEXT\n)" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+0", "command": "editor.action.insertSnippet", "args": {"snippet": "(\n\t$TM_SELECTED_TEXT\n)$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "shift+[", "command": "editor.action.insertSnippet", "args": {"snippet": "$0{\n\t$TM_SELECTED_TEXT\n}" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "shift+]", "command": "editor.action.insertSnippet", "args": {"snippet": "{\n\t$TM_SELECTED_TEXT\n}$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` [" , "command": "editor.action.insertSnippet", "args": {"snippet": "$0[\n\t$TM_SELECTED_TEXT\n]" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` ]" , "command": "editor.action.insertSnippet", "args": {"snippet": "[\n\t$TM_SELECTED_TEXT\n]$0"}, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+,", "command": "editor.action.insertSnippet", "args": {"snippet": "$0<\n\t$TM_SELECTED_TEXT\n>" }, "when": "editorTextFocus && editorHasSelection"},
{"key": "alt+` shift+.", "command": "editor.action.insertSnippet", "args": {"snippet": "<\n\t$TM_SELECTED_TEXT\n>$0"}, "when": "editorTextFocus && editorHasSelection"},
Из них только первый полезен в вашем случае.
Сначала вам нужно выбрать выражение, либо с Ctrl Shift ◀ ◀ ... ◀ , либо, если ваша языковая поддержка расширение достаточно умное, с Alt Shift ▶ ▶ ... ▶ (он же editor.action.smartSelect.expand
) .
Затем вы нажимаете ( (он же Shift 9 ) и получаете |(Math.random() * 5)
, где |
- курсор. Вы вводите имя функции.