1

I would like to have the following feature on VSCode and I don't know if it is possible. For example, if I have this line :

I would like to emphasize this.

I would just select this, clic on a shortcut like ctrl+i and then this appears :

I would like to emphasize {i}this{/i}.

I use a lot of {i} and {/i} tags in my project so this would help me save an incredible amount of time !

I know VSCode already does something similar when you select a word and clic on "

Lanfeust
  • 55
  • 2
  • 6
  • See https://stackoverflow.com/questions/60593920/setting-character-to-wrap-text-as-parentheses-in-vscode/60594017#60594017 for example, that answer wraps with a `$`. If you need help modifying it to wrap with your tags let me know. – Mark Mar 16 '20 at 00:51
  • Thank you @Mark ! Works fine :) My question is in fact a duplicate but i couldn't find it as i didn't use the same words – Lanfeust Mar 16 '20 at 01:33

1 Answers1

4

Find your keybindings.json file and insert the following snippet:

{
  "key": "ctrl+i",
  "command": "editor.action.insertSnippet",
  "args": {
    "snippet": "{i}$TM_SELECTED_TEXT{/i}"
  },
  "when": "editorTextFocus && editorHasSelection"
}

Key bindings can be found by pressing Ctrl+Shift+P > type "Keyboard shortcuts", full name being: Open Keyboard Shortcuts (JSON).

Yuan-Hao Chiang
  • 2,484
  • 9
  • 20