5

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 "

2
  • See stackoverflow.com/questions/60593920/… for example, that answer wraps with a $. If you need help modifying it to wrap with your tags let me know. Commented Mar 16, 2020 at 0: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 Commented Mar 16, 2020 at 1:33

1 Answer 1

7

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.