简体   繁体   中英

Wrap a highlighted string in custom text in VSCode

An example:

I'm sick of writing $log.debug(myWord);

Is there any way in VSCode I can double click myWord to highlight it and hit a binded key or run a command that inserts $log.debug( before and );after?

This was solved by opening up "Open Keyboard Shortcuts (JSON)" via ctrl+shift+p and adding the following item:

[
    {
        "key": "alt+shift+e",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "snippet": "\\$log.error(\"${TM_SELECTED_TEXT}\", $TM_SELECTED_TEXT$1);"
        }
    }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM