9

In Dreamweaver I'm used to insert code snippets with my own keyboard short cuts. Now I'm trying to change to Visual Studio Code 1.2.1 but cannot find any way to do this? (I don't like how intellisense works entirely)

I found the Key Bindings json file for changing the behavior, but no command for inserting my own code snippets or macros.

a basic example of what I want to achieve.

select the text "string" & press Ctrl + 1 macro to execute:
insert before string <div>#
insert after string #<div>

result

<div>#string#</div>
ROOT
  • 11,363
  • 5
  • 30
  • 45
user2523216
  • 143
  • 1
  • 7
  • If you read the following page you can create your own snippets very very short string prefixes. https://code.visualstprefix'sudio.com/Docs/customization/userdefinedsnippets. – klewis Jun 19 '16 at 00:31

1 Answers1

10

keybindings.json >>

{
    "key": "ctrl+1",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
        "snippet": "<div>#${TM_SELECTED_TEXT}#</div>"
    }
}

https://code.visualstudio.com/docs/editor/userdefinedsnippets#_assign-keybindings-to-snippets

Alex
  • 59,571
  • 22
  • 137
  • 126