how to edit advanced new file extension vs code to work without a workspace - visual-studio-code

I found this extension called advanced-new-file by patbenatar in vs code that lets you create files anywhere with a custom directory you can create on the spot and things like that, but it only works when using a workspace. There is another one called Advanced New File by Dominik Kundel that sort of does the same thing but anywhere even if you have no workspace opened, but it has a bit less features. Does anyone know how I can modify the first one so that I can use it without having to create/open a workspace?

Related

Where does VSCode save the context about open files?

I am aware that I am asking for an implementation detail but I want to hack something for my use case and hence the question.
My use case: I use an on-demand instance where source code is hosted at work. This means I get a new machine (let's say every day) where I open the same source folder (but hosted on that remote machine). Because of this, the context of opened files in editor gets lost between sessions.
I am curious where does VSCode save the information about open files in a workspace. If I know that, I am hoping I can copy that file at the end of day before I give up an on-demand instance AND when I get the next instance (which may have a different remote url but same file paths), I can somehow hack this file to open all the editors from previous session in the new on-demand. Does my question make sense? Let me know if something is not clear.
On Windows the workspace state is stored here:
%APPDATA%\Code\User\workspaceStorage
And on Linux:
~/.config/Code/User/workspaceStorage
Every workspace has a subfolder here with a hashed name. To find out which one belongs to your workspace, open the contained workspace.json, which looks like this:
{
"folder": "file:///c%3A/some/path"
}
Choose the one that matches your workspace folder and copy the complete folder.
However, I am not sure how VS Code calculates the hashes for the folder names, so maybe it won't use the same hash again in your new instance. But this definitely is the place where the information is stored, so it's worth a try.

Why is a folder named ".dist" automatically created in VS Code?

Everytime I open a folder or create a workspace, VS Code automatically generates a ".dist" folder and it has been bugging me for quite a long time now and I still do not understand why it even exits in the first place.
It does not seem like there is any problem in deleting the folder.
For me, it is just some bloat that automatically generates when said conditions are met.
I would really like to find if there is a setting which I can toggle ON that disables the auto-generation of the ".dist" folder.
This is due to an extension you have installed which makes it to help with compliling or running. Sass/Less/Typescript/Jade/Pug Compile Hero Plugin is probably the extension that does this.

How to prevent VS Code remembering files outside work folder?

My workflow with VS Code is to always use project folders on projects. This works great, but there's one thing that's messing things up right now;
When opening just a single file from another project while working in another project, lets's say webpack.config.js, I use Windows Explorer rightclick to open that file in VS Code. However, this always opens the file in the currently open VS Code instance.
This adds the file from that other folder now to the memory of the previously opened files in the open project while it has nothing to do with that project.
When using the quick file open of VS Code now it happens a lot VS Code opens a file from that other folder, only because that outside file has been opened once while I was working on this project.
This is error prone as now it happens a lot, especially when working fast, that the wrong, for instance, package.json or webpack.config.js file gets opened, because VS Code now also suggests files that are outside this project. That's pretty frustrating and causes changes to be made in the wrong files pretty quickly.
I know we can clear the editor history and have to do it a lot now. But to me that's the other way around, doesn't solve the real problem and when not done often the issue remains.
So I want to get rid of this issue and have the following questions:
1) How can we change the 'Open with Code' rightclick menuitem in Explorer to open files always in a new instance of VS Code?
2) Is there a config settings to disable the behaviour that VS Code remembers files that are outside of the current work folder?
Thanks in advance, this thing is bothering me for quite some time now!
How can we change the 'Open with Code' rightclick menuitem in Explorer to open files always in a new instance of VS Code?
I assume you are a Windows user. You can edit the context menu behavior from Regedit.
Follow the below steps:
Press Windows + R
Type regedit and press OK
Go to Computer\HKEY_CLASSES_ROOT\*\shell\VSCode\command in regedit
Add -n parameter to the command like below
It will help you to open every file in a new window when you use Open with Code.
For your second question, Is there a config settings to disable the behavior that VS Code remembers files that are outside of the current work folder?
Open VS Code settings
Search window.openFilesInNewWindow
Make it off to on like below
With this configuration, you can't open new files in the current workspace therefore technically you prevent VS Code remember outside files. Not directly but it helps.
I don't like how "recently opened" files are shown in VS Code Quick Open (Ctrl+P). I think OP is describing this behavior...
The behavior to remember "recently opened" files causes me problems when I mistakenly open a temporary/copy of my file, i.e.
C:/users/temp/code.js
... instead of the true file (i.e. located inside the currently-open VS Code project)
C:/git/source-control/code.js
...my confusion happens because because both files are listed among the options when I use Quick Open Ctrl+P and type "code"
For me , the Quick Open list also has the answer, any "recently-open" files should have an "X" icon on the right side. You may need to hover your mouse over the file you want to remove.
Click the "X" icon to "Remove from recently open". Quick Open will always be able to find files in your current project, even if you remove them from recently-open:
Please note I don't have access to regedit as suggested in the accepted answer; my answer here does not require regedit

Can you create a file or folder by path in VS Code?

In Atom, hitting Cmd+N brings up a window where you can type in basically any path to create any file or folder anywhere in the project. In VSCode, hitting Cmd+N brings up a dialog where you can create a file in the currently focused folder, and I believe you can type a path to create a file in a subfolder (whether it exists or not), but not as flexibly as in Atom.
Is there way to do it Atom-style in VSCode?
I don't know for sure whether this is what you're looking for, but still there exists this plugin which can emulate the file/directory creation feature of Atom.
Since i use vscode-vim it's fairly easy to create new folders and files using command mode. If you're familiar with using terminal, then you can use shell commands to create file/dir.
I have no idea whether one could do what you had mentioned the proper way with vanilla vscode.
Hope this helps you somehow.

Guide won't automatically generate an m file

I am working in matlab gui GUIDE and I am trying to rename a file. I open the fig file in GUIDE and save it as the new file name but a new .m file is NOT created. Consequently I cannot run the gui or edit the file. I have seen a lot of posts about this and many people say "Save As" should just work which is strange because it was working for me yesterday too. Does anyone know the reason why sometimes GUIDE does not automatically generate an m file?
The two files MUST have the same name. See the documentation here: http://www.mathworks.com/help/matlab/creating_guis/files-generated-by-guide.html
Further more, I can't find specific examples in the documentation, but there seems to be a common issue with Callbacks and UI property names getting a little messed up. The best bet is of course is to not touch the file names (or create the GUI programmatically) but now that the damage is done, I would reccommend:
Making sure both files have the same name
Checking all button callbacks to make sure they point to the right file
Checking the tag of all your graphics objects to make sure they are the sames
Double check in your GUIDE options that it is still set to generate an mfile ( Tools > Gui options > Create m file )
Best of luck, GUIDE can be good, but is very far from perfect. (especially in times like now)