Reputation: 145
I really like the auto surround feature in VS Code, where you highlight some text and type a character like (
or [
and it surrounds your highlighted text with (
)
or [
]
, respectively. I recently downloaded a VS Code extension that enables LaTeX formatting with Markdown files, and now I want to add the character $
as one of these "auto-surrounding" characters (statements surrounded by $
characters are rendered with LaTeX).
I have done some digging in the VS Code documentation and around the web, but I can't find where I could manually add my own custom characters for auto-surrounding. This page in the official documentation seems most promising. I can't figure out where this file lives though (or if there is a way for me as a user to edit it).
Upvotes: 4
Views: 1618
Reputation: 137097
This isn't something that you can change via preferences. You'd need to modify the Markdown extension itself. This is entirely possible, but as VSCode updates it will overwrite your changes and you'll have to make them again.
Find the markdown-basics
extension in your VSCode installation. On my Windows 10 machine, it is in C:\Users\me\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-basics\
. If you're on another operating system, look for the resources/app/extensions/markdown-basics/
directory inside your VSCode installation path.
Open up the language-configuration.json
file. This will probably have been minified, so I suggest you format the document via the context menu, a keyboard shortcut (Shift+Alt+F on Windows), or the command palette. Then add
[
"$",
"$"
]
to the existing array of surroundingPairs
. Save, and you should be good to go.
While you're in there, you might also want to update the autoClosingPairs
, e.g. by adding this:
{
"open": "$ ",
"close": " $"
}
You might need to restart VSCode for this to take effect, e.g. if the plugin was already loaded.
Upvotes: 5