You can create a code snippet for your function call by going to File
> Preferences
> User Snippets
and selecting the language you're working with (in this case, Python). Then, select "New Global Snippets file" and enter a name for your snippet file.
{
"myfunc": {
"prefix": "Surround with...",
"body": [
"${1:function}(${TM_SELECTED_TEXT})"
],
"description": "Wrap selected text with function()"
}
}
Ctrl-Shift-P
, select Open Keyboard Shortcuts (JSON)
and add:
[
{
"key": "ctrl+shift+8",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly",
"args": {
"langId": "python",
"name": "myfunc",
},
}
]
Now you can select some text and press Ctrl+Shift+8
, and simply enter the name of the function!