Tips and Tricks
- You can view the source code side-by-side with the Preview (after
selecting the code type in the bottom right):
- To wrap code around the selected text (https://stackoverflow.com/a/73344832/2029527; archived
at https://perma.cc/P5JA-7DBC):
- Press
Ctrl
+Shift
+p
- Type and select “Open Keyboard Shortcuts (JSON)”
- Add the following item:
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "<TEXT-BEFORE>$TM_SELECTED_TEXT</TEXT-AFTER>"
}
}
]
- Save the
keybindings.json
file.
- Select the text you want to wrap, and press
Alt
+Shift
+e
Example Code
Snippets
Template
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "<TEXT-BEFORE>$TM_SELECTED_TEXT</TEXT-AFTER>"
}
}
]
\begin{equation}...\end{equation}
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "\\begin{equation}\n$TM_SELECTED_TEXT\n\\end{equation}"
}
}
]
LS0tCnRpdGxlOiAiVmlzdWFsIFN0dWRpbyBDb2RlIgotLS0KCmBgYHtyIHNldHVwLCBpbmNsdWRlID0gRkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldCgKICBlY2hvID0gVFJVRSwKICBlcnJvciA9IFRSVUUsCiAgY29tbWVudCA9ICIiLAogIGNsYXNzLnNvdXJjZSA9ICJmb2xkLXNob3ciKQpgYGAKCiMgVGlwcyBhbmQgVHJpY2tzCgoxLiBZb3UgY2FuIHZpZXcgdGhlIHNvdXJjZSBjb2RlIHNpZGUtYnktc2lkZSB3aXRoIHRoZSBQcmV2aWV3IChhZnRlciBzZWxlY3RpbmcgdGhlIGNvZGUgdHlwZSBpbiB0aGUgYm90dG9tIHJpZ2h0KToKIVtWaXN1YWwgU3R1ZGlvIENvZGVdKGltYWdlcy92c0NvZGUucG5nKQoxLiBUbyB3cmFwIGNvZGUgYXJvdW5kIHRoZSBzZWxlY3RlZCB0ZXh0I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