How to move a Visual Studio Code workspace to a new location painlessly? - workspace

I thought VS Code saves all the relevant metadata in .vscode folder and .code-workspace file and as these are contained within the workspace folder I assumed it's all self-contained and shouldn't cause problems when moved. But apparently I was gravely mistaken.
After moving my workspace folder to a new location and altering folder paths saved in .code-workspace file accordingly all my opened editor panes and the bottom panel are gone. What I have now is a nice Welcome window.
I'm aware of what the official guide recommends, but that's only moving .code-worskpace metafile - the folder still stays in place.

I've just run into the same issue. My workspace wasn't saved to a file at all (I just use the "Open with Code" option on each project folder), and the Save Workspace As option didn't help as it just created a JSON file with a couple of empty objects in it (which probably makes sense as I haven't really modified any workspace settings, I just want to preserve my open editors and things like that).
On Windows at least, it seems that those kinds of "workspace" settings are actually stored within subfolders of %APPDATA%\Code\User\workspaceStorage, and an SQLite database file is used to store the actual settings, so this is what I ended up doing:
Move your folder to the new location on disk (close all VS Code windows first)
Open the new folder location with VS Code (you'll just get the Welcome tab at this stage, but we just need it to create a settings storage folder for the new location). Then close VS code again.
Open %APPDATA%\Code\User\workspaceStorage in File Explorer, go into each subfolder and open workspace.json (in any old text editor). In my case at least, it only contains a folder property, which is path of the folder that this settings folder relates to (but just changing this won't help us at all, it was the first thing I tried). Use this to figure out which of these subfolders relate to the old and new paths.
Copy state.vscdb from old to new, and delete state.vscdb.backup in new.
Open state.vscdb in new in some sort of SQLite database file editor (I used DB Browser for SQLite and it worked fine, but there's also SQLiteStudio which looks like it might be better in general).
Run an UPDATE query to update all the paths in the database. They seem to be stored in three different formats/levels of escaping - between folders there can be a forward slash, two backslashes, or four backslashes. In my case I wanted to move my project folder from the root of my Windows user folder into my usual documents folder which is within OneDrive, so my query was along the lines of the following, as I only needed to change the middle section of each path. You might have to do something more complicated if you are moving to a different drive for example (would need to have a look at all the existing paths in the database to see how they are encoded).
UPDATE `ItemTable` SET `value` = REPLACE(REPLACE(REPLACE(`value`, 'User/Project', 'User/OneDrive/Documents/Project'), 'User\\Project', 'User\\OneDrive\\Documents\\Project'), 'User\\\\Project', 'User\\\\OneDrive\\\\Documents\\\\Project')
After saving the database, I just opened the new folder in VS Code, and everything seems to have loaded up exactly as it was in the old location :)
(Also just in case anyone is curious, the subfolder names in workspaceStorage seem to be some sort of hash based on the path, because if you delete the subfolder that relates to a folder you've previously opened in VS Code and then open that folder in Code again, it recreates the same subfolder name. So that means just updating the old workspace.json and database file in-place won't work)

Scenario 1 - Moving the .code-workspace file The xxx.code-workspace file that defines your project folder location(s) is in JSON format. It has a "folders" section and a "settings" section. If you just mant to move the location of the xxx.code-workspace all that is needed is to go to File->Save Workspace As..., browse to the new location, select the name you want to give the workspace and it will save it with a .code-workspace extension. All of the "path" entries in the "folders" section are changed to a path relative to the new location.
Scenario 2 - Moving the entire workspace. If you want to move the entire workspace to a new location and the .code-workspace file is in the root directory of your workspace, just move the old workspace to the new location. The contents of the .code-workspace file will still be correct. Just select File->Open Workspace..., navigate to the new location and open the .code-workspace file.
Scenario 3 - When you .code-workspace folder is stored in a different location. If you store all of your .code-workspace files in a location apart from the actual workspace, the simplest way to move the workspace is a two step process:
With your workspace open, do File->Save Workspace As... and save the .code workspace file to the root directory of your workspace.
Move the workspace to the new location.
File->Save Workspace As... and save the .code workspace file to its location.
Close VS Code and delete the .code-workspace folder that's in the root directory of your resource, so that future settings changes will be saved to the correct workspace.

Related

index.sublime-project and index.sublime-workspace files

I have a directory named project, and I navigated to Project > Add Folder to Project... in order to see the directory tree in my left sidebar. I noticed that doing this creates a file called index.sublime-project with the following content:
{
"folders":
[
{
"path": "."
}
]
}
I also noticed that there is another file in my directory called index.sublime-workspace, although this one does not appear in the tree view on the left sidebar of Sublime. It is only visible through windows explorer when I navigated to the Project directory.
What is the purpose of these files? Can I prevent them from being created every time I add folder to project?
Adding directories to the window using Project > Add Folder to Project is indeed one of the ways to open a folder (the others being to drag and drop a folder onto the window and File > Open Folder).
However, doing so do not create those files. To create them, you would need to use the Project > Save Project menu item. So you may have accidentally done that without realizing it. In theory a plugin could also create those files for you, though that seems unlikely (anything is possible though).
In any case, assuming you don't want them it's entirely safe to remove them.
A sublime-project file is a file that allows you to open folders in the side bar and then do things like apply settings that apply only to files in that window, alter what files and folders appear, and so on.
A sublime-workspace file is a localized session information for a particular window. Usually, they associated with a sublime-project file but they don't have to be. They store the state of the window, open files, etc so that you can close a window and then recall it later with the same state.

Moving a file somewhere else on hard drive

I have been searching for a way to move a project folder to a different location on my drive and still be able to use it in Sublime Text. After moving the folder, Sublime Text will not save changes because it says the file is missing.
Every editor stores a project location as a reference. Your sublime text is still looking for files from your previous location.
You can simply add a new project choosing you new project location.

Viewing all descendant files in TFS/VS

Is it possible to see all descendant files in the marked folder in the Source Control Explorer window in Visual Studio?
Other source control software I have used have this option, and it makes it very easy to iterate through all the files in a folder recursively and see what has changed.
I think TFS does not support this feature, but there are others options available :
Pending Changes
You don't need to iterate through all the files to see what has changed. You can view easily what has changed using Pending changes. A pending change is a change (Add, Edit, Delete ...) that has not been check-in in TFS. You can view these changes for a single directory or the whole Project. In addition, you can check-in pending changes only for one directory. You will always see the summary window to view all changes before. Right-click the item (Folder or File), and you will see options : Check in, Undo or Shelve. More info here.
File & Folder Comparison
In Source Control Explorer, you can compare the differences between two server folders, two local folders, or a server folder and a local folder. Simply right click on the target folder. It's quite a powerfull feature when you know it.
Read morehere.

Total Commander How to feed list listbox with selected files

Just like Search result can feed the listbox (which opens new temporary tab),
is there a way to:
simply select files from one directory and feed the listbox?
select files from multiple directories and feed the same listbox?
Just to rename listbox's temporary tab and you could have favorite list of items over which you could perform more actions. This would increase productivity tremendously!
Regarding #1:
After you select the files activate:
Menu > Show > Only Selected Files
Regarding #2:
It's probably not what you were after, but you can use DiskDir / DiskDir Extended to add files (using a packer functionality, so you create an 'archive' file with extension .lst which contains a hierarchical list of the added files. You can then change source folder and then add more files. Later you just click on the .lst file and it looks no different then your normal file / folder list. Unfortunatelly you cannot rename the files, but you can launch them, with an extra confirmation.
UPDATE
Similar functionalitybut with 'source' renaming functionality limited to one file only (?): Virtual Panel, (File System Plugin, accessible through the Network Neighborhood 'drive'). It can launch files without a confirmation window. Rename 'source/target' file when you use it's own subbar (located here: %%COMMANDER_PATH%%\Plugins\WFX\VirtualPanel\EN\VirtualPanel.bar, make sure that you also have installed the AskParam addon and have paths in the VirtualPanel.bar right (both to AskParam.exe and VPBatch.exe). 'Regular' rename will change the file name only in the virtual panel.
URL: Virtual Panel Plugin

How to exclude a folder and not its children from SVN Update in Tortoise SVN

I am working on a shared project which is put in SVN. The directory structure of the project is as follows:
ParentDir
- Child_Dir_1
+ GrandChild_Dir_1
+ GrandChild_Dir_2
- Child_Dir_2
Child_Dir_1 contains configuration files (Eclipse's .LAUNCH files), and people put all sorts of file in this folder.
So each time I update my source code (by right clicking on ParentDir and picking Update), I got a lot of configurations that I don't really need, and I have to delete them manually.
I still need to have the children of Child_Dir_1 (which are GrandChild_Dir_1 and GrandChild_Dir_2) to be updated.
I have tried to go to set the "ignore" property of the of Child_Dir_1 to exclude *.LAUNCH files, but each time I update the source code, the ones that I manually deleted are restored to Child_Dir_1.
Since you are using TortoiseSVN:
Go into Child_Dir_1, select GrandChild_Dir_1 and GrandChild_Dir_2 and right click, TortoiseSVN -> Update.
That will update only those two folders.
Ignore is so that you can "ignore" ( from commit, status etc.) untracked files, files that are not checked in.
It could be that manojlds' answer is the solution for you, but I have doubts. The problem here is that those files are really part of the project. They are kind of unavoidable, and must be in sync with the rest of working copy.
Option 1 (best): Remove all configuration files form repository, or better yet have in repository only configuration template files (with, say, $ as first character in file names). Each user could copy those template files to true configuration files and change them accordingly. Configuration files should not ever be committed. Only template files should, but updating template files will not mess with current configuration files of any user.
Option 2 (second best): Ignore those configuration files. Use your own files for your own configuration, with names that don't clash with existing. You may even add your files to SVN, but you may just as well not add them. Does not matter, as long as you don't need your configuration on another machine.
Option 3: Use ignore-on-commit group. Use those configuration files that already exist. Change them to your likings, but don't ever commit them. To ensure that you don't commit them by accident flag them as non-committable (go to commit window, select all non-committable files, right click > Move to changelist > ignore-on-commit). The problem with this is your files are not protected from other users' updates, but may actually be a good thing.
Option 4: Chop the folder out (a horrible hack). Remove Child_Dir_1 from working copy (Right click on it > Update to revision > set Working depth to Exclude). Save the folder elsewhere first, because it will disappear. After that create it again, inside it checkout all subfolders (GrandChild_Dir_1 and GrandChild_Dir_2), and copy your configuration files. Now you have complete control over folder's contents, but update and commit become more complicated.
Edit: There is option 5 in theory, but I doubt it can be implemented successfully. You can try: Use NTFS hard links. Copy the whole tree with all files as hard links to existing files, except .svn folders and their contents. Original directory is used for SVN operations update, commit, add and delete, and new directory is used for editing files. From new directory delete all the files you don't need, and insert all the files you do need that are not the part of SVN. The problem here is minor extra work when deleting files from and adding them to SVN.

Resources