-
-
Notifications
You must be signed in to change notification settings - Fork 391
Sync Pragmas
received_693912302877334.mp4
Settings Sync supports per-os and per-host inline settings and keybindings by using Sync Pragmas.
You can ignore certain settings in settings.json
or keybindings.json
by using the @sync-ignore
pragma.
// settings.json
{
// @sync-ignore
"window.zoomLevel": "1", /* won't upload to gist */
}
// keybindings.json
[
// @sync-ignore
{
"key": "alt+v",
"command": "workbench.action.closeActiveEditor",
"when": "editorTextFocus"
}, /* won't upload to gist */
]
There are 3 different keywords that can be used with Sync Pragmas:
- host
- os
- env
After configuring a hostname for your computer, you can use the host
keyword to only include certain parts of settings.json
or keybindings.json
.
// settings.json on "home" computer
{
// @sync host=home
"window.zoomLevel": "1"
}
The os
keyword can also be used to only include certain parts of settings.json
or keybindings.json
.
Currently, there are 3 operating systems supported:
- windows
- linux
- mac
// settings.json on linux
{
// @sync os=linux
"window.zoomLevel": "1"
}
Settings Sync can check for the existence of environmental variables using process.env
to only include certain parts of settings.json
or keybindings.json
.
// settings.json on a computer with the environmental variable "CODE_ZOOM_1" set
{
// @sync env=CODE_ZOOM_1
"window.zoomLevel": "1"
}
// settings.json on "home" computer running Linux
{
// @sync host=home os=linux
"window.zoomLevel": "1",
// @sync host=work os=windows
// "window.zoomLevel": "0",
}
// settings.json on "work" computer running Windows
{
// @sync host=home os=linux
// "window.zoomLevel": "1",
// @sync host=work os=windows
"window.zoomLevel": "0",
}
// settings.json on "work-pc" running Linux
{
// @sync os=linux host=work-pc
"python.autoComplete.extraPaths": [
"/blah/blah/python2.7/site-packages",
"/usr/lib/python2.7/site-packages",
],
// @sync os=windows host=home-pc
// "python.autoComplete.extraPaths": [
// "C:\\Program Files\\blah\\site-packages",
//],
}
// keybindings.json on "home" computer running macOS
[
// @sync host=home os=mac
{
"key": "alt+v",
"command": "workbench.action.closeActiveEditor",
"when": "editorTextFocus"
},
// @sync host=work os=linux env=CODE_WORK
// {
// "key": "alt+q",
// "command": "workbench.action.closeActiveEditor",
// "when": "editorTextFocus"
// }
]
// keybindings.json on "work" computer running Linux
[
// @sync host=home os=mac
// {
// "key": "alt+v",
// "command": "workbench.action.closeActiveEditor",
// "when": "editorTextFocus"
// },
// @sync host=work os=linux env=CODE_WORK
{
"key": "alt+q",
"command": "workbench.action.closeActiveEditor",
"when": "editorTextFocus"
}
]
A hostname can be configured by editing syncLocalSettings.json
. To open it, simply run > Sync: Advanced Options => Edit Configuration
and change hostName
from null
to your desired hostname.
// syncLocalSettings.json
{
... other settings
"hostName": "<YOUR HOSTNAME>",
}
Before uploading your settings from settings.json
or keybindings.json
, all settings with inline pragmas are uncommented. Then, when your settings or keybindings are synchronized, all the settings or keybindings values with pragmas that don't match with your machine (OS, hostName or ENV variables) will be commented. Therefore VS Code won't apply them.
[ [ { "metadata": { "id": "d10af6bf-270f-4cf0-b94b-1bea4bda1e2e", "publisherId": "nrwl.angular-console", "publisherDisplayName": "nrwl" }, "name": "angular-console", "publisher": "nrwl", "version": "17.6.1" }, { "metadata": { "id": "d3836729-9cc1-42c1-b2af-d50071f57d29", "publisherId": "formulahendry.auto-close-tag", "publisherDisplayName": "formulahendry" }, "name": "auto-close-tag", "publisher": "formulahendry", "version": "0.5.11" }, { "metadata": { "id": "6e440e71-8ed9-4f25-bb78-4b13096b8a03", "publisherId": "formulahendry.auto-rename-tag", "publisherDisplayName": "formulahendry" }, "name": "auto-rename-tag", "publisher": "formulahendry", "version": "0.1.7" }, { "metadata": { "id": "70378119-1d85-4935-9733-0298c7a369a2", "publisherId": "steoates.autoimport", "publisherDisplayName": "steoates" }, "name": "autoimport", "publisher": "steoates", "version": "1.5.4" }, { "metadata": { "id": "697255a9-3f36-44c8-b084-d3b91edfb23a", "publisherId": "HookyQR.beautify", "publisherDisplayName": "HookyQR" }, "name": "beautify", "publisher": "HookyQR", "version": "1.5.0" }, { "metadata": { "id": "b689fcc8-d494-4dbf-a228-2c694a578afc", "publisherId": "alefragnani.Bookmarks", "publisherDisplayName": "alefragnani" }, "name": "Bookmarks", "publisher": "alefragnani", "version": "13.1.0" }, { "metadata": { "id": "f583eafd-aa0d-4ccb-8f44-d1e610389660", "publisherId": "CoenraadS.bracket-pair-colorizer", "publisherDisplayName": "CoenraadS" }, "name": "bracket-pair-colorizer", "publisher": "CoenraadS", "version": "1.0.61" }, { { "metadata": { "metadata": { "id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd", "id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd", @@ -78,265 +8,5 @@ "name": "code-settings-sync", "name": "code-settings-sync", "publisher": "Shan", "publisher": "Shan", "version": "3.4.3" "version": "3.4.3" }, { "metadata": { "id": "f60a60a6-95ba-42d4-b41c-3d24c1b89588", "publisherId": "EditorConfig.EditorConfig", "publisherDisplayName": "EditorConfig" }, "name": "EditorConfig", "publisher": "EditorConfig", "version": "0.16.4" }, { "metadata": { "id": "5960f38e-0bbe-4644-8f9c-9c8824e82511", "publisherId": "donjayamanne.githistory", "publisherDisplayName": "donjayamanne" }, "name": "githistory", "publisher": "donjayamanne", "version": "0.6.17" }, { "metadata": { "id": "b63c44fd-0457-4696-99e9-dbfdf70d77de", "publisherId": "ritwickdey.LiveServer", "publisherDisplayName": "ritwickdey" }, "name": "LiveServer", "publisher": "ritwickdey", "version": "5.6.1" }, { "metadata": { "id": "5db78037-f674-459f-a236-db622c427c5b", "publisherId": "PKief.material-icon-theme", "publisherDisplayName": "PKief" }, "name": "material-icon-theme", "publisher": "PKief", "version": "4.8.0" }, { "metadata": { "id": "1b0d4512-2735-4323-ae6b-30c0f58cdbb0", "publisherId": "herrmannplatz.npm-dependency-links", "publisherDisplayName": "herrmannplatz" }, "name": "npm-dependency-links", "publisher": "herrmannplatz", "version": "1.2.0" }, { "metadata": { "id": "dff6b801-247e-40e9-82e8-8c9b1d19d1b8", "publisherId": "christian-kohler.npm-intellisense", "publisherDisplayName": "christian-kohler" }, "name": "npm-intellisense", "publisher": "christian-kohler", "version": "1.4.0" }, { "metadata": { "id": "fef63133-dae3-40fb-b81d-6da7617b4b1e", "publisherId": "techer.open-in-browser", "publisherDisplayName": "techer" }, "name": "open-in-browser", "publisher": "techer", "version": "2.0.0" }, { "metadata": { "id": "0d1241e3-fa60-4f24-8f2a-6d7085677c48", "publisherId": "ionutvmi.path-autocomplete", "publisherDisplayName": "ionutvmi" }, "name": "path-autocomplete", "publisher": "ionutvmi", "version": "1.17.1" }, { "metadata": { "id": "a41c1549-4053-44d4-bf30-60fc809b4a86", "publisherId": "christian-kohler.path-intellisense", "publisherDisplayName": "christian-kohler" }, "name": "path-intellisense", "publisher": "christian-kohler", "version": "2.4.0" }, { "metadata": { "id": "96fa4707-6983-4489-b7c5-d5ffdfdcce90", "publisherId": "esbenp.prettier-vscode", "publisherDisplayName": "esbenp" }, "name": "prettier-vscode", "publisher": "esbenp", "version": "8.0.1" }, { "metadata": { "id": "6a2bbab0-d8f0-43fa-9b26-e6a3b7892a0b", "publisherId": "mtxr.sqltools", "publisherDisplayName": "mtxr" }, "name": "sqltools", "publisher": "mtxr", "version": "0.23.0" }, { "metadata": { "id": "75da638c-c45a-44ea-aa3b-8570a3559810", "publisherId": "TabNine.tabnine-vscode", "publisherDisplayName": "TabNine" }, "name": "tabnine-vscode", "publisher": "TabNine", "version": "3.4.17" }, { "metadata": { "id": "bf8aa94a-4051-42fe-9bd1-2becad466fe7", "publisherId": "Equinusocio.vsc-community-material-theme", "publisherDisplayName": "Equinusocio" }, "name": "vsc-community-material-theme", "publisher": "Equinusocio", "version": "1.4.4" }, { "metadata": { "id": "45bfc9eb-5e03-487f-bffe-315fa6881d6a", "publisherId": "Equinusocio.vsc-material-theme", "publisherDisplayName": "Equinusocio" }, "name": "vsc-material-theme", "publisher": "Equinusocio", "version": "33.2.2" }, { "metadata": { "id": "6959958f-be4d-42c4-8aa4-dc2c2f086b0a", "publisherId": "equinusocio.vsc-material-theme-icons", "publisherDisplayName": "equinusocio" }, "name": "vsc-material-theme-icons", "publisher": "equinusocio", "version": "2.0.10" }, { "metadata": { "id": "0b8f8d63-11a2-4194-969c-ca7488b3413a", "publisherId": "pranaygp.vscode-css-peek", "publisherDisplayName": "pranaygp" }, "name": "vscode-css-peek", "publisher": "pranaygp", "version": "4.2.0" }, { "metadata": { "id": "583b2b34-2c1e-4634-8c0b-0b82e283ea3a", "publisherId": "dbaeumer.vscode-eslint", "publisherDisplayName": "dbaeumer" }, "name": "vscode-eslint", "publisher": "dbaeumer", "version": "2.1.23" }, { "metadata": { "id": "6aef71bc-661a-4042-ad05-d2e190b39082", "publisherId": "moppitz.vscode-extension-auto-import", "publisherDisplayName": "moppitz" }, "name": "vscode-extension-auto-import", "publisher": "moppitz", "version": "1.3.3" }, { "metadata": { "id": "c727ab43-8d12-4f26-9648-f1d91035c9b6", "publisherId": "NuclleaR.vscode-extension-auto-import", "publisherDisplayName": "NuclleaR" }, "name": "vscode-extension-auto-import", "publisher": "NuclleaR", "version": "1.4.3" }, { "metadata": { "id": "8bd907de-999c-4f06-9be1-f74a06da52fb", "publisherId": "georgewfraser.vscode-javac", "publisherDisplayName": "georgewfraser" }, "name": "vscode-javac", "publisher": "georgewfraser", "version": "0.2.39" }, { "metadata": { "id": "6fc9fa34-b8b2-4071-9a0d-3eeb81cd9cfb", "publisherId": "fknop.vscode-npm", "publisherDisplayName": "fknop" }, "name": "vscode-npm", "publisher": "fknop", "version": "3.3.0" }, { "metadata": { "id": "d7ffabfa-4c17-4635-b905-309b6470cc35", "publisherId": "howardzuo.vscode-npm-dependency", "publisherDisplayName": "howardzuo" }, "name": "vscode-npm-dependency", "publisher": "howardzuo", "version": "1.2.2" }, { "metadata": { "id": "ae9e3eb0-3357-4cc0-90ee-598d2d384757", "publisherId": "eg2.vscode-npm-script", "publisherDisplayName": "eg2" }, "name": "vscode-npm-script", "publisher": "eg2", "version": "0.3.22" }, { "metadata": { "id": "5a7017bf-c571-4d77-b902-6e56b16f539a", "publisherId": "johnpapa.vscode-peacock", "publisherDisplayName": "johnpapa" }, "name": "vscode-peacock", "publisher": "johnpapa", "version": "3.9.1" }, { "metadata": { "id": "876e8f93-74d0-4f4f-91b7-34a09f19f444", "publisherId": "VisualStudioExptTeam.vscodeintellicode", "publisherDisplayName": "VisualStudioExptTeam" }, "name": "vscodeintellicode", "publisher": "VisualStudioExptTeam", "version": "1.2.14" }, { "metadata": { "id": "0cb81da2-1880-4755-9995-0ae9cc728e20", "publisherId": "DotJoshJohnson.xml", "publisherDisplayName": "DotJoshJohnson" }, "name": "xml", "publisher": "DotJoshJohnson", "version": "2.5.1" } } ]