How to prevent Visual Studio Code from opening abc.exe in editor? - visual-studio-code

I've just started with Visual Studio Code.
One thing I find really strange is, if my code compiles to an *.exe, and I select it in the explorer, VS Code tries to "open" it, as if it was a text file, and then complains it's a binary file.
Ideally, it should do nothing when I select it, and I should have to easy way of running it if I want, like "double-click" or some option in context menu. I don't want to hide the .exe, I just want VSCode to know it cannot edit it, so it shouldn't try.
[EDIT] In case someone wonders why I'd single-left-click on something where that click "makes no sense", it's because I've spent the last 15 years using an IDE where that does nothing except select the file in the explorer, and so I got into the habit of click on things while I'm "thinking about it", for example when I'm talking about this file to someone else. That's a hard habit to get rid of, in particular since I'm still using that IDE in my "day job".

As far as I know, this is not possible. There aren't any settings to control this and extensions can't block an editor from opening.
An extension COULD automatically close any tabs that were opened for a .exe file. So if you clicked on it and a tab opened, the extension could close it. I don't know if such an extension exists.
Otherwise you can create a feature request on github: https://www.github.com/microsoft/vscode/issues/new

Related

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

Visual Studio Code Automatic Preview Mode on Sidebar navigation?

I've recently moved to Visual Studio Code from Sublime Text.
Something that I'm missing is the "automatic preview mode" (I don't know the exact name): in ST, if I navigate the files in the sidebar with the keyboard, every file is automatically opened in a (static) preview editor.
I couldn't find anything similar in VSC. The most similar functionality requires me to single-click, but I have two problems with this:
I'm a "keyboard-prevalent" user, and (single-)clicking defeats the purpose;
in ST this happens automatically, so it's faster anyway.
Am I missing something?
I've been searching for a while, but can't find anything relevant. It seems there are references to this functionality from Search Files (Ctrl+P), but I'm looking this functionality on the sidebar, since I use this while working on files of a single directory.

How do I turn off "Contains emphasized items" in Visual Studio code?

I need to figure out how to turn off emphasized items in Visual Studio Code
This might sound like a strange requirement, but in my workflow vscode functions as less an IDE than a cross-platform ViM-esque frontend with lots of remote development tools built-in.
Due to this use case, I don't need or want the linting features to show up in the file browser. How might I accomplish this?
Attempts to solve the problem
I've run out of search terms here and cannot find an answer.
Searches including terms in this question's title yielded little
SO-specific search queries also yielded little
This seems to be somewhat related, at least as a representation of the "feature" I'm referencing: VS code containes emphasized items but no error
VSCode "preferences" do not appear to show what I'm looking for, likely an issue with me not searching for the right variable name.
In my experience with VSCode it has been wonderfully customize-able, so I'm guessing there's a setting somewhere ready to be modified to accomplish this. Any help much appreciated, thanks!
My use case was a bit different: after viewing some files in a git submodule those files became linted, and errors and warnings cluttered up my VS Code Explorer file browser window on files I had no intention of ever handling. I basically wanted a way to clear out those lint warnings, and found it here. The solution is to reload the window:
CtrlShiftP on Windows/Linux, ⌘ShiftP on Mac -- then select "Developer: Reload Window"
One by-product of reloading the window is that it clears out those unwanted warnings (at least until the next time I visit the file). It also has the effect of clearing out warnings on files that I would normally want to see, of course, but chances are I'll be visiting those files again soon, so it's fine. Not a perfect solution, but it works for me and my use-case; hopefully it can help others.
I don't know how to turn it off, but I had this on multiple folders and I fixed it by renaming the folder to a random name, then naming it back to the name it was before and the error would go away.
If you have this issuse then uninstall extention then CtrlShiftP on Windows/Linux, ⌘ShiftP on Mac -- then select "Developer: Reload Window" then type developer: relode page this issuse automatically resovle
i have this issuse then i uninstall extension then this issuse resolve.
I was able to permanently prevent this by adding the files to the .gitignore file. It seems that this happens in a cloned repository when you add new files.

VS Code: when I close a sub-folder and return to the file, the sub-folder reopens

I've always developed with Sublime Text, but I feel that VS Code is much better, so I want to get started.
I have a problem please (with Sidebar of VS Code):
When I open a sub-folder in my project, and I open a file that is inside, I like to manually close this sub-folder (because I like to see the architecture of the project, etc.) and to continue working on its files which are already open in my editor.
For example (I work with Laravel): if I open a "User.php" file which is in the "App/Modals" folder, then I manually close the "App/Modals" folder, then I will work in another file, then I come back to work in "User.php", the "App/Modals" folder reopens by itself ...
I do not have this behavior with Sublime Text, nor with PHP Storm.
SVP: Is there a regulation to prevent this behavior?
Thank you.
There's an option to make this feature (it's not something that's just happening to you, it's a feature of VSCode) go away. Go to settings (ctrl + , or cmd + , on mac) and search for "explorer.autoReveal". Make sure it's unchecked, or set it to false in your setting's json.
Just by the way, I don't know if you did, or you didn't know what to search, but you should try to solve this kind of problems by googling for an answer. For instance, I didn't know the answer, but a simple 'disable auto opening folder vs code' in google brought me several results. Just a recommendation, so that you can learn how to solve your own problems and be more efficient.

Double clicking to open a file doesn't work with Visual Studio Code

I am using Visual Studio code and it works fine except that double clicking the file doesn't seem to open the file. Instead the Program just opens with an Untitled.txt screen.
Right click -> Open with code also works.
How do I make it work? I am using Windows 8.
This wasn't the case some versions back, but now it seems, that it actually is the expected behaviour. The developers intentionally do not register VSCode as the default open handler (don't ask me why).
But maybe there is a workaround. Try the following steps:
1. Try to associate the filetype(s) with another app, and then again to VSCode.
2. If setting to other editors and returning to VSCode still opens Untitled-1.txt, then you could
3. try reinstalling VSCode, and then reset it. When resetting, confirm that there is only one VSCode in the choice list.
It also could be, that you'll need to reboot your machine. Finally, you'll possibly also want to take a look at this issue on GitHub.
Hope you can solve it this way.