NerdNoob
NerdNoob

Reputation: 75

How to reference custom file location for snippets in Visual Studio Code. System wide. Not Project specific

Goal: To find a VSCode setting that I can update to have VSCode reference a custom file or folder location to store and save my code snippets. System wide and not project specific.
OR find a way to have the default VSCode settings files reference/import settings from a settings file in a different file/location.


Why: I have a personal dotFiles git repo that I maintain updated with all my latest configs, settings, shortcuts, themes, etc. for a lot of the tools that I use.

This makes it easier to start working on a new machine or an infrequently used machine (VMs, laptops, etc.).
I just pull latest from my git repo and I get all my latest custom settings.

For a lot of the tools I use, I can usually put a reference in the default settings file to reference my custom settings file, that is in the dotFiles repo location.


Example from my dotFiles repo ReadMe.md:

Default user .gitconfig file location is usually in the user home folder.

Add this include line to reference this synced .gitconfig

[include]
    path = <Path to this folder's .gitconfig>

Make sure that you escape the \ characters correctly on windows.


This way when I switch between computers, I just do a git pull and I instantly bring over and apply my custom git settings and shortcuts on the machine I'm currently working on.

Whenever I need to update my .gitconfig settings I update the .gitconfig in my dotFiles repo, which has version control and change history, and I magically have those changes both in my dotFiles repo and actively used on my machine without having to copy and paste between files and trying to remember when the latest copy-over was done and if I had pulled latest from the repo.

So all these files:

They are all practically one and the same. Always in sync. Across all the machines I use.

I have this setup for a lot of my tools: .git, .vimrc, .bashrc, etc. etc.


I guess this is the same issue I had with trying to have VSCode reference the keybindings.json and settings.json in my ~/dotFilesRepo/visualStudioCode/ folder instead of the default location VSCode location.

I know we can have project specific snippet settings as mentioned in this previous post: (Change the snippets location in Visual Studio Code)
But that is different than what I need.

I also realize that there is a Sign in option to VSCode that allows you to Backup and Sync settings.
But that does not provide me with the same level of use and control as my dotFiles git repo. Aside from my dotFiles repo already backing up and syncing all my other tools settings. I also use machines (VMs) that are a bit more locked down and limited in terms of network access, where the VSCode Sign in functionality would be blocked by the network but I would still be able to sync my approved git repo.
That VSCode Sign In to Backup and Sync is different than what I need.

I want to change the base path of the user snippets system wide.
Not just project wide.
OR have a way to have the default settings files import and include settings from a personal settings file.

I am trying to avoid having two files or folders for the same snippet settings and having to constantly and manually copy between them.

I also use Azure Data Studio which is built on top of VSCode.
I would like a cleaner solution so that I can have my VSCode and Azure Data Studio: settings, keybindings, and snippets
in one location: dotFiles repo

Eventually I will also have to figure out how to keep my VSCode snippets in sync with my RedGate Snippets and MS SQL Management Studio Snippets. But one step at a time.

Upvotes: 0

Views: 24

Answers (0)

Related Questions