Sync vscode instances - visual-studio-code

I'm setting up a new machine and want to have as much synced between my two machines as possible. I use vscode as my main editor and would like, if possible, to have the two instances synced. I'm wanting to copy some settings folder to my iCloud drive, and then symlink it back to it's location on my local drives.
If I did this, will open files sync in real time, or only on startup? Will this likely lead to anything being corrupted? Is this even possible? Finally, what folder must I sync?

I'm doing exactly this nowadays (after using Settings Sync for a while) – syncing settings via my iCloud folder.
The content of ~/Library/Application Support/Code/User is what you are looking for.
I linked keybindings.json and settings.json and they both work fine without hickups so far. You might want to sync the folder snippets too.
workspaceStorage makes no sense to sync because they are specific to the workspaces you open on a single machine.
It works basically "out of the box". Even if a new setting gets not picked up instantly by a running VSCode instance if it syncs in the background while open, you can always cmd+shift+p Reload Window or open and close the settings (I almost never have to do this).

Related

Where are the information about each workspace stored?

I know that some settings such as imported folders are store on the workspace file such as my-worskapce.code-workspace and some others such as python interpreter are stored in the root folder(s?) such as .vscode/settings.json but these do not include information about opened editors or which extensions are disabled for each workspace etc. Where can I find those information?
I need that information because I started storing all my *.code-workspace files in ~/ and now it's getting cluttered and I want to move them to a different folder, when I do, and reopen my workspace, I see that all open editors are gone! This hurts my productivity as I will have to reopen them and recall which files were being worked on. And another issue is that previously added folders are gone too! I have to re-add them which is merely a redo of work that already has been done, since imported folders are imported as relative paths. If I move the *.code-workspace file to it's original location with the same name however, everything is back to normal, so this tells me VSCode is storing information about each workspace somewhere and it's bound to each *.code-workspace absolute path. I have checked ~/.config/Code/User but couldn't find anything. I've googled a lot using different keywords but seems it's nowhere documented or asked about. I usually make backups of my workspace files and I'd like to make back up of these information as well.
In windows you can find them in
C:\Users\<username>\AppData\Roaming\Code\User\workspaceStorage
VS Code 1.75 introduced a new Profiles feature, summarised here.
Profiles store information such as user settings, installed extensions and the current layout of panels etc.
You can export/import profiles to/from a Github gist or a local file. Different profiles are associated with each workspace.
Profiles won't resolve all your immediate issues, but may give you more flexibility in the future.

How do I recover lost extensions, after using Settings Sync

I've built a new pc, and I'm trying to transfer all my VS Code settings from my old pc to my new one. And I came across Settings Sync within VS Code. I sign in on both machines using my GitHub account. I click Sync Now, it somewhat works in that only five of my extensions show up on my new PC, I have over 100. But then on my old pc all but those same 5 extensions
for some reason, gets removed.
For a brief moment, I was able to get all my extensions back on my old pc by clicking in the sync activity (remote) tab and restoring to a previous state. The problem is, whenever I open a new window, they're gone again. Now when I try to restore a previous state, it just loads those same 5 extensions only.
I came across this post Recover lost settings + extensions and more?
And I tried JΛYDΞV's suggestion. I can see the backup JSON files which contain info for all my extensions when I view it in Windows explorer. However, when I try to view them in VS Code under the Sync Activity (Local) panel, I get this error:
Cannot read properties of undefined (reading 'id')
Would anyone have any other ideas as to how I can get my extensions back on either machine?
I should also add that before I tried any of this I did actually copy the entire VS Code folder under AppData\Roaming to an external hard drive and for the heck of it overwrote that same folder on my new pc just to see if that would remedy the problem, but then however no extensions show on my new pc.
Would anyone have any more steps I could try? The last thing I would want to do is to have to add all those extensions again

Revert/Reload all open files in Visual Studio Code?

I have been trying to figure this out, and cannot determine if it is possible or not.
Essentially, I commonly work with a VSCode window containing many files located on an external network drive (CIFS mount in Linux). When these files are changed "on-disk", they do not update in the editor until I switch focus to each file by changing the active editor tab. This means I have to switch tabs, wait for the update to process, and then repeat for all open tabs (could be 10 or 20 tabs).
Is there anyway to force all open editors to refresh or revert at once? That would ease my workflow a lot for examining differences between these open files on the fly. There's a command to "Revert File", but that only works on the open file, rather than all currently-opened ones. I've looked in the settings and browsed for an extension, but I can't find anything to accomplish this task.
Well, You can try to map the external network drive to local disk and give appropriate permission for read and write restriction.
If your computer has firewall or anti virus installed, then you must exclude vs access restriction from fw/av inspection.
Otherwise you can also improve your network adapter performance, associate to buffers, throughput, packet latency, etc.
Alternatively, you can use any source control, so your codes could be persist locally and could be synchronized from/to source control server.
Hope this could helps.

Prevent VS Code from opening all files in a folder recursively

I am currently using VS Code on a folder mounted through an SSHFS. The folder has subfolders with many jpg and other image files.
Logging all the files VS Code tries to open reveals it recursively touches all the files (doesn't read the content, just STATs them). This takes very, very long over an SSHfs mount and I can not cancel it without killing the editor (it won't even respond to regular closing).
During this, no files or directories can be opened (inside VSCode) and will show a loading spinner until VS Code has finally had it's way and checked all the files.
This behaviour only recently emerged, I can't pinpoint if any version beyond the current stable version has this behaviour.
I am thinking it might be the new searching engine, but I can't find out which part of the editor is doing it.
It looks like they just posted a fix for your situation:
Slow startup opening a large workspace over the network
you will need vscode v1.32.3

Is there auto-syncing in netbeans for external changes

I know netbeans syncs the original files once I save, but if there is a file changed externally is there a way for netbeans to recognize this and either tell me to re-sync it or automatically resync it with the new changes?
Here's what makes this behavior possible:
NetBeans 6.9 contains a feature that automatically looks for external changes to keep informations about files up-to-date. We have some reports that it can slow down NetBeans mainly, when an open project has many folders. When NetBeans find out that files were externally changed, it re-scans the files to keep data up-to-date that are used with features like code completion, navigation etc. Unfortunately the notification and following re-scanning can take some time and during this time many mentioned features are waiting for the finishing of scanning. There is option Enable auto-scanning of sources that can switch off this behavior. The option you can find it in Options dialog, Miscellaneous category and Files tab.
The default behavior is that NetBeans also looks for external changes when the main window gets focus. This is can be during developing a web application very often when user switches between browser and IDE. The mentioned option also switch this off.
When you switch off option Enable auto-scanning of sources you can still keep the information up-to-date, just invoke Scan for External Changes action from Sources menu manually.
(Here's the original article by Petr Pisl)
I find it counterproductive to leave this setting on, as sometimes auto-loading external changes to a file opened in the UI without asking for permission first can ruin your day when you're forced to make small local changes that you don't want replicated in your repository. I'm sure other people can think of more reasons to advocate for "warn before loading external changes" behavior to be implemented in NB. That is one of the reasons why I like Eclipse better sometimes.