How to prevent vscode as default program to run html file? - visual-studio-code

When I double click a html file, it will be automatically opened in vscode. I set Firefox as default program and it works fine, but every time after I reboot, Visual Stadio Code - URL Handler still be the default program to open a html file.
I use linux mint 18.3, it only happens after vscode upgrade to 1.28

Right click on the file in the chosen format and choose Open With... -> Other Application or Open With Other Application.
Don't forget to check the Remember this application for "..." files checkbox to apply your selection for all files of the same format.
As discussed here

Related

How to let VS Code open file using the default program of the operating system?

I am using the latest VS Code to write python Qt code (under Ubuntu 20.04). One obstacle is that VS code does not recognize known file types such as .ui files, and opens it as raw text or xml file.
By comparison, other editors such as eclipse opens the .ui file with its OS default program -- Qt Designer. With VS Code, I had to open a file manager and then find and double-click the file to open it the right way (the same as opening the file using xdg-open in terminal), which is quite inefficient.
Does anyone know of a way to configure VS code to open a known file directly using its OS default program?
There are two extensions that I know of that tackle this problem (no affiliation):
Open in External App
... with this extension, you can do it more simply. Just right click to the file, and select Open in External App, that file would be opened by system default application. You can also use this way to open .psd files with photoshop, .html files with browser, and so on...
The configuration implies that you need to manually set which app to use for which extension, so it doesn't simply use the default configured in your OS (at least not in my brief test).
Open
Opens files using the OS's default program for the file type
This does what it says out of the box, but the keyboard shortcut seems to fail. The command can only be triggered via the right-click menu of the file in the vscode file browser.

How to change folder that opened by default in VSCode?

I have small problem with VSCode folder, that opened by default.
Problem description: I start new instance of VSCode (trough File->New Window), and then if I choose File->Open Folder it opens dialog with my Windows user folder as starting point (C:\Users\MyUser)
Question: How can I change that folder in settings (if it possible)? So by default it will show as start point for example D:\development\ ?
At the time I write this answer, this is not possible. There are two problems on Windows, and one problem on Mac and Linux:
VS Code does not provide a default path to the file dialog 1. It does remember the last folder that you opened a file in, but that path cannot be used as a default because it is overwritten constantly.
On Windows only, Electron ignores the default path when creating a file dialog if the default path is a directory 2.
An extension also cannot solve this, because extensions are not allowed to modify the File menu 3.
I think the best option at this point is to pin a folder to the Quick Access area in Windows Explorer, as suggested in a comment, or to put an actual shortcut in the user profile folder.
Workspaces and File > Open Recent may also be helpful if you often open the same folders.
Your main problem is that you are unable to open your specific folder in VScode.
To solve that you can simply open the terminal/cmd in that specific window by just typing cmd in your search bar or just by pressing shift+right-click in that folder.
Now your cmd is open and you just have to type "code ." in the cmd and press enter to open the current folder in your VSCode.
In case that code . doesn't work for you then you have to add the Vscode in the environment variables of your windows.
Visual Studio doesn't provide a specific feature to open a specific path. But there is a solution to your problem. You are saying that you want D:\develpment as a default when you open VS Code. You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.
make a shortcut on the desktop for vscode and then modify it and add the folder after the .exe command. This will default open that folder when you double click on it.
Visual Studio Code can be installed in two ways - User setup and System setup. I strongly believe you have User setup installed in your PC. Try re-installing it System-wide. That should probably fix your problem.
For more information: https://code.visualstudio.com/docs/setup/windows#_user-setup-versus-system-setup
PS: A lot more information is needed, you can share a screenshot of the window and elaborate more on it.

Script editor does not open in Spark AR Studio

I have installed Spark AR Studio on Windows. I was able to work with basic effects. However when I tried to create a Script asset and open it up, it keeps failing with the error code 800A03EA. Source is shown as Microsoft JScript compilation error. I can see the file using Notepad and it only has two line in there.
// How to load in modules
const Diagnostics = require('Diagnostics');
const Scene = require('Scene');
SparkAR Studio tries opening your scripts with the default editor assigned to .js files on your operating system.
Assign Visual Studio Code / Sublime / etc. to be your standard way of opening .js files on Windows and SparkAR will open it when you click on it
To set default editor for Js files you can just create empty js file - right click on it - choose default program to open and go to your favourite editor (sublime, vscode, etc). That's all
Set Atom/VS code/Sublime as your default JS editor.
Right click on the script.js file and a menu window will open. Click on 'Reveal in Explorer' and it will take you to the location. There, right click on the script.js file and open it with any other editor (e.g. Atom).

How to open a binary file (e.g. Excel) in Visual Studio Code with its default application

I use Visual Studio Code to work on projects that not only include program code, but also data files, e.g. in Excel format.
VSCode cannot edit such files, as they are binary. Attempting to do so shows a warning, and if you persist, the file is shown (as gibberish).
I've also tried to pass the file to the (CMD) terminal (right click, 'Open in Terminal'). In a regular CMD window that would invoke the default application, but that does not work in VSCode.
Is there a simple way that I can use from VSCode to open such files using the default applications?
The extension sandcastle.vscode-open does this. Install it, and you can open any file with its default application by right clicking on the filename in the explorer menu.
In v1.66 you can set a default editor for binary files and avoid the warning (see release notes: binary file):
Default binary editor
A new setting, workbench.editor.defaultBinaryEditor, lets you
circumvent the binary file warning and automatically open the editor
type of your choosing when a binary file is detected. You can select
the default binary editor from a dropdown in the Settings editor or
via IntelliSense in settings.json.
TBH, I am still investigating whether you can set this to some external application like Excel?

Visual Studio Code: Auto-refresh file changes

Working with Visual Studio Code I have noticed if a file you are working with change, whenever that file get focused in a code panel it will be reloaded from the disk (if you don't have changes in the file through VSCode).
However, if you are on that file there is no alert to warning you about file changes.
I've been reviewing the settings and I cannot find anything like the visual studio option:
Detect when file is changed outside the environment
So my question: Is there any hidden setting or some hack to make that warning happen.
Update
Solved in version 0.3.0 of Visual Studio Code.
The file will be updated from disk if there is no changes through the editor. (very useful to read log files during a process execution)
If there are changes on both sides (from disk and through the editor) when ever you try to save the file using VSCode, the editor will warn you about that situation (i.e. "dirty writes") and a file comparison will allow you to decide what to do.
VSCode will never refresh the file if you have changes in that file that are not saved to disk. However, if the file is open and does not have changes, it will replace with the changes on disk, that is true.
There is currently no way to disable this behaviour.
{
"files.useExperimentalFileWatcher" : true
}
in Code -> Preferences -> Settings
Tested with Visual Studio Code Version 1.26.1 on mac and win
SUPER-SHIFT-p > File: Revert File is the only way
(where SUPER is Command on Mac and Ctrl on PC)
In version 1.57.1 (June 2021) there is still no setting like Detect when file is changed outside the environment.
But if the file was accidentally changed outside, you can easily revert the changes with just the Undo (Ctrl+Z) command
On Ubuntu, after creating a new file using vscode, it doesn't show up until I refresh the explorer manually. It's really frustrating. There was a key I changed in settings.json and everything worked fine after that:
"files.legacyWatcher": "on",
save, restart the vscode and be safe :)