How to move a file to another folder in VS Code? - visual-studio-code

Given the file tree:
x/y/a.txt
How do I move the file up to:
x/a.txt
When right clicking on the file I just see delete and rename but not the move command.
A google search did not reveal anything about this.
I use vscode 1.6.1
Update: It is currently impossible to move files and folders to the root folder: https://github.com/Microsoft/vscode/issues/1043

Move is available by right-clicking the file in the sidebar after installing File Utils from the Visual Studio Code Marketplace.

You can use drag n' drop to move the file

You can also move file with using console (for example PowerShell or Git Bash) in Code.
Recently I have I habit to move files or folders in sidebar, via ctrl + x (cut) and ctrl + v (paste), after this action Code automatically updates imports.
Drag & drop method also works.

The OP issue 1043 which was resolved with VSCode v1.37 (2019)
That feature is still improving, with issue 98309: "Support multiple files in working copy file service".
See PR 98988 "File operation events support multiple resources"
That allows other files which depends on the move to be properly updated when you are moving several files.
That will avoid this:

Related

How to rename files in VS Code in bulk?

Is there a way to search for ALL .txt files in a project and automatically replace/rename them to .js?
E.g user.txt to user.js
It seems I can't search for a file format in VS Code.
If you know how, please share!
You could just do it in the terminal.
mv *.txt *.js
You can use a combination of:
Filtering the EXPLORER panel to just show .txt files
See "Filtering the document tree" section of the VS Code docs
See related Stack Overflow post: "Filter files shown in Visual Studio Code"
Installing and using the Batch Rename extension
For example, given these files/folders:
Steps:
Start by clicking on the EXPLORER panel and filtering to just display .txt files
Select/highlight all the files, then right-click on any selected file, then select "Batch Rename"
That would open a text file ".Batch Rename.txt" with all the selected files
Do a regular find-and-replace to change .txt to .js
Note that the ".Batch Rename.txt" is unsaved. It's like a preview of what the changes would look like
Save ".Batch Rename.txt" and it will automatically close
The EXPLORER panel should now be empty since it's filtered on .txt
Remove the filter and the files should now be renamed
You can use find to do this in a terminal recursively.
find . -iname "*.txt" -exec rename .txt .js '{}' \;
refer Find multiple files and rename them in Linux
mv works if you want to just do it in a folder itself.
Old question, I know, but for you or anyone else coming in, if you're okay with using a non-VS Code solution, there's a GUI Windows tool called RegexRenamer that is so well-named, you already know what it does.
It gives you a preview of what the renamed files will look like, and has options to rename everything in subfolders or only the current folder, ignore/include file extensions in the search, and apply the rename only to folders/files or both.
What do you think?

Restore a deleted file in the Visual Studio Code Recycle Bin

Using Visual Studio Code Version 1.8.1 how do I restore a deleted file in the recycle bin?
It uses the normal trash bin of your system. So you can grab it our of there.
In Windows you find it in the explorer, in Linux it is as well in Konquerer / Nemo / ...
First go to Recycle Bin of your local machine.
Your VS code deleted files is there in Recycle Bin.
So, Right click on deleted files and select-> Restore option then your deleted files
will be automatically restored in your VS code.
If you just deleted the file, know that VSCode 1.52 (Dec. 2020) will support:
Undo file operations in Explorer
Explorer now supports Undo and Redo for all file operations: delete, rename, copy, move, new file and new folder.
Make sure the focus is in the Explorer and trigger the Undo or Redo commands and your last file operation will be undone or redone respectively.
Keep in mind that we have separate undo stacks for the editor and the explorer and we choose which one to undo based on focus.
Running on Ubuntu 18.04, with VS code 1.51.0
My deleted files from VS Code are located at:
~/.local/share/Trash/files
Every deleted file have a corresponding .trashinfo file which contains details about where the file is deleted from and deletion date and these are located at:
~/.local/share/Trash/info
More info here.
To search for your deleted files:
find ~/.local/share/Trash/files -name your_file_name
In case you deleted files form a mounted ntfs filesystem, they will be located at:
/path_to_mounted_fs/.Trash-$UID
You can get $UID by doing echo $UID in your terminal.
Hope my case helped!
Click in empty space of VS Code's explorer (it's where you see files listed vertically) and press undo Ctrl + z
It'll recover your permanently deleted files too.
VS Code is a lifesaver. ✌
I know the OP says Recycle Bin. What I do though is recreate the file, especially if it's a single file. And when in the file, I just press CMD+Z (I'm on a Mac) and I get my file back.
Recreate the file in the same directory from where it was
deleted.
CMD+Z inside of the newly created file.
I accidentally discarded changes in the Source Control in VS Code, I just needed to reopen this file and press Ctrl-Z few times, glad that VS Code saves your changes like that.
If you can't find your files in the Windows Recycle Bin as it happended to me
(debugger went rogue and deleted the project folder)
look in the %APPDATA%\Code\User\History\ subfolders sorted by date modified.
There I could retrieve my seemingly lost files.
who still facing the problem on linux
and didnt find it on trash
try this solution
https://github.com/Microsoft/vscode/issues/32078#issuecomment-434393058
find / -name "delete_file_name"
If you have permanently deleted files, on macOS, you can see the history (the last month I guess) in $HOME/Library/Application Support/Code/User/History/. You will have to find your file(s) by looking at each entries.json file in every subfolder and rename the last version of your file.
There is probably a similar way on windows and linux but I don't know the precise paths.
I tried most of the options above but none worked.
What worked for me was clicking and highlighting the folder where the file was deleted from in vscode. Then while it is selected, hit CTRL + Z.
This works on windows.
Hitting CTRL+Z without highlighting that folder didn't work.
Just look up the files you deleted, inside Recycle Bin. Right click on it and do restore as you do normally with other deleted files. It is similar as you do normally because VS code also uses normal trash of your system.
While pushing a repository to Github through Vs Studio code I deleted whole folder and they were not available in Recycle bin also. Here is how I recovered those files.
For Windows.
The method is to restore the previous version of the Drive in which the deleted file existed
I had deleted files from G: drive, the below images are self explanatory
Open properties menu of the drive
In properties go to previous versions tab,
where you can find the previously stored versions of that drive along with date at time of backup
use open or click on restore to get the previous version of that drive.
Note: Manipulations in the drive after restore point won't be available
I am not sure how I deleted a file in VS Code, and couldn't find it in recycle bin. Found the file using the History feature of File Explorer.
A month recovery can be done in visual studio code
1 Right click on file and
2 click Open Timeline and
3 select file from timeline
4 the last time file saved by you
5 and your last change of the file is recovered
NOTE : Not only last but all the previously saved check points can be recoverd from vs code
For Mac, try to search some parts of the code in the deleted file in the following path:
~/Library/Application Support/Code
I found a deleted file in this folder
~/Library/Application Support/Code/Backups
Yes, I know this question is about VS Code but I think I can help someone.
I permanently deleted a file, and I tried all the tips wrote here with no success. So I had to recover the file from OS Linux following this
grep -a -C 500 -F 'Unique string in text file' /dev/sda
It was asked above if there is a way to disable the ability to delete a file you created with an undo (#rochasdv).
There is a new setting to disable undo for file operations:
Explorer: Enable Undo default is warn, confirmation dialog
You can also set it to disable so that your files/folders will not participate in undo operations.
You can alo set it to allow - the pre-new setting situation.
Currently, this new setting is in the Insiders Build v1.64 so it may be in Stable early February, 2022.
I am working on Windows with a Ubuntu WSL. I permanently deleted a file by mistake and was not able to restore it from the recycle bin nor by doing anything else.
I however, was able to get my files content by going to "Timeline" and see all my previous modification (it will open a comparison window).
Hope it will help somebody.
I had the case that I, accidentally, deleted a committed file (git) with a ton of additional uncommitted changes, and I could not get it back. (two days of work! yeah, I know, commit early commit often, I know ...)
I had no linux trash can setup on my docker instance and was developing via remote ssh.
I tried to recreate the file and then do a ctrl+Z to recapture the changes as some suggested here. This did not work for me.
So after a struggle over an hour I finally gave up and thought the changes to the file were lost.
However,
I discarded the changes in git, that the file was deleted.
And THEN I retried ctrl+Z and boom all the changes previously came back
magically!
I was a happy camper!
If your local directory has git initialized and you have not committed the changes that include the delete, you can use git checkout -f to throw away local changes.
If you completely delete any of the components in angular using visual code, you can restore it
Go to Recycle Bin and restore the deleted component that will be restored in the project.

Change .vscode folder location

I'm programming a client side applications using SharePoint Designer 2013.
I want to change to VSCODE since it supports a lot of extensions for some Javascript library like angular, jQuery. And because of the Chrome/Node.js debugger extension.
But when I try to start any Debugger, I got the error:
Unable to create 'launch.json' file inside the '.vscode' folder (Error: UNKNOWN: unknown error, mkdir '\\servername\DavWWWRoot\sitename\Style Library\.vscode').
I get this error because it's impossible to create a folder in SharePoint where the name starts with dot.
So there's a possibility to change the name of this folder or the file location to any directory in my local computer?
No, it's not possible to move/rename that folder. VS code is a tool that bases project management on folder content. So it is essential that the project settings reside in the folder being managed.
You can move the "extensions" folder, but unfortunately not the argv.json (so the ".vscode" will, at least be recreated on vscode launch)
https://github.com/microsoft/vscode/issues/17691#issuecomment-559234574
I hope that'll finally change sometime .
https://github.com/microsoft/vscode/issues/3884
https://github.com/OmniSharp/omnisharp-roslyn/issues/953

wrx file handling with Developer Studio

Is there a way to make Progress Developer Studio 3.7 (Eclipse) generate all the wrx files (from the ocx) and place them in for example the rcode folder?
Clarification:
I dont know even how to make one wrx file. Have heard this "They get automatically created as soon as you drop an OCX control onto an ABL frame". But if you have removed that file, can you create it anew without having to redrop the control? And how do you automatically place it in a certain folder?
wrx files contain the properties of an ActiveX you set in the appbuilder.
If you loose the wrx, those properties revert back to default values. You should check-in the wrx files into your version control system together with the source .
To copy the wrx to the rcode directory I use robocopy.
suppose your sources are in a directory named src then you can copy them using
robocopy src rcode *.wrx /s
The wrx-file is generated when compiling in the AppBuilder.
See this entry in the Progress Knowledge base

Deploy a Desktop Shortcut to a Device running Windows CE 4.2 (VS2005)

I have an application written using VS2005 in C# targeting the Compact Framework 2.0 SP2. As part of the solution, I have CAB deploy project which deploys to the device without a problem. What I can't do is create a shortcut to my application on the devices desktop.
I have spent several hours reading various bits of documentation (why is the search at the MSDN site so bad?), followed the instructions but no joy.
What I've done is:
Add the "Windows Folder" node to the File System
Created a folder underneath that named "Desktop"
Created a shortcut to the Applications Primary Output and placed that in the "Desktop" folder
What am I missing?
A bit late but maybe this will help somebody like me who searched for this issue, I solved the problem like this:
I added a custom folder on the root node (File System on Local Machine) and called it %CE3%.
That is the shortcut for \Windows\Desktop.
I added my shortcut (right click create new shortcut) and gave it a name.
That's it, then I build!
When analysing the Shortcuts section in the inf generated, it looked good.
[Shortcuts]
"ShortCutName",0,"MyApp.exe","%CE3%"
And when I deployed and it worked perfectly!
I'm using VS2008 and deploy on windows CE 5.0
Here is a list of shortcuts: windows CE shortcuts
A Windows CE shortcut (CE of any version or flavor, including WinMo) uses a ASCII-text based file. They are in the form:
{XX}#{PATH}
Where:
XX = the number of the characters in the path, to include the number a # sign
PATH = fully qualified path to the file to run
For example:
20#\Windows\calc.exe
The other option is to use the CEShortcuts section of the INF file used to generate your CAB.
In the [DefaultInstall] section of the INF, set the CEShortcuts to a section name of your choice (something like "Shortcuts"), then add that section with your shortcut descriptor. MSDN details it here.
MSDN also has an article on creating a deployment project to generate the cab (available here), but in all honesty, the project capabilities are limited and IMO the tool just generally sucks. To this day we still use direct calls to CABWIZ (which also sucks, but it's our only choice) with hand-written INF files.
I had this same problem and found a simple solution, if anyone still needs this.
Instead of adding a windows special folder, just add a custom folder named Windows, then a folder within it named Desktop, and put the shortcut there.
This worked for me.
The Simplest way is to go into the Application folder in Cab Project(setup), right click on your EXE Program(Application exe that you want to make shortcut for) and chose "Create Shortcut to" and move that file to any folder you want such as "Start Menu Folder"
Mitch: create the LNK file as before, but give it a name like "shortcut.lnkx" (note the "x" on the end). You can then add it to the "Desktop" folder in your CAB project. Once the file is added, change the TargetName property to "shortcut.lnk" and compile. I think this will work.
Assuming that you use Windows Mobile (5.0 or 6.x) you could use that syntax to create a file as a shourtcut(*,lnk):
SHORTCUT = XX#"\Program Path..."?\Icon File Path...,-Icon Number
Where:
XX = Count of characters to be included in arguments after the Program Path to process.
Program Path = Target exe file location.
Icon File Path = If exe file does not contain an icon image or you want to use another, this is the location of the file containing the icon image.
Icon number = Index of icon image within the file, it starts with 0.
Ex: 86#"\Storage Card\Logical Sky CEdit\cedit.exe"?\Storage Card\Logical Sky CEdit\cedit.exe,-101
I had test it, and works fine.
1.Copy the file.
2.Go to desktop (or wherever you want to create the shortcut).
3.Right click on an empty space, click Paste Shortcut.
That's it.
Actually, this is pretty simple ! (Using VS 2008 and Smart Device CAB project)
1- In the solution explorer on VS, Go to your CAB project and right-click on it.
2- Go to View -> File System
3- Here, on the left column, right-click and "Add Special Folder"
4- Select Start Menu Folder for the shortcut folder
5- Go to the Application Folder just above
6- On the right column, right click on the Primary output and select "Create shortcut to bla bla bla"
7- Then you just have to move it to the start menu folder on the left and rename the File :)
OPTIONAL: You can even add fonts to the device using "Fonts folder" in the "Add Special Folder" menu !
Cheers
I assume that you're working with a "Smart Device CAB Project"? I don't think this project creates shortcuts in the correct manner for Windows CE 4.2. I think you can download an SDK from Microsoft that after installation will show you something like "Windows CE CAB Project" as a project option.
I think you can do this manually, though. A Windows CE shortcut is a file with a *.lnk extension, so if you want a shortcut labeled "My Application", create a text file on your PC named "My Application.lnk". The file's contents should be:
46#\Program Files\My
Application\MyApplication.exe (the # should be the full path length)
or whatever full path your application has on the Windows CE device.
In your CAB project, continue with adding the "Windows" folder and then the "Desktop" folder as you were. In the Desktop folder, right-click and add the LNK file that you created. You may have to soft-reset the device in order to have the shortcut show up after installation.