I got fed up constantly having to copy shared configuration files (tasks.json, settings.json, launch.json and cpp_properties.json) into every folder in my project (there are hundreds) so this extension simply adds a command Copy Global Config
to copy them into the local .vscode folder from a common location.
In-built support for shared config is apparently on the radar (for standard vscode and for the cpp extension), but it seems to be taking a while, so this might be useful until it arrives.
To use:
- Place your default files (e.g.
tasks.json
,settings.json
,launch.json
, etc.) in a folder somewhere. By default, the extension will look in~/.vscode/
. - If you choose a different folder, open your settings and point
global-config.folder
to that folder. - Open a new VSCode window and run the
Global Config: Copy Global Config
command, to copy (or link) the files into your local folder (.vscode).
Note: Existing files will not be replaced.
When used in a multi-root workspace folder, the global files are copied into each workspace .vscode folder.
You can also put multiple sets of default files into subfolders of your configured source folder. When running the copy command, it will prompt you to choose one of the subfolders first. Note, using subfolders will ignore any files in the configured source folder.
You can install the latest version of the extension via the Visual Studio Marketplace here.
Alternatively, open Visual Studio code, press Ctrl+P
or Cmd+P
and type:
> ext install global-config
The source code is available on GitHub here.
global-config.folder
Use this to set which folder should contain your shared config files. The default is ~/.vscode
.
global-config.links
This is an array of files which should be symlinked instead of copied. This is useful for files which may change in the future, e.g. settings.json
Note: For symlinks to work correctly under Windows 10 (and possible other Windows versions) you will need to run Code in Developer Mode.
global-config.hardLinks
This is an array of files which should be hard linked instead of copied.
global-config.destinations
This is an mapping of files to alternative destinations. Note: paths are absolute, but you can use ${workspaceFolder}
, or other environment variables and make them relative from there.
For example,
"global-config.destinations": {
".gitattributes": "/home/user/workspace",
".gitignore": "${workspaceFolder}/..",
".defines": "${HOME}/temp"
}
Notes:
Links, hard links and destinations can also use glob patterns to match files. Links and hardlinks settings are still applied to files copied to alternative destinations.
When the Copy Global Config is run, an output channel is created in the Output View. If the extension doesn't seem to be doing what you expect, please check the contents of the output channel.