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

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?

Related

vscode the file is not displayed in the editor because it is either binary or uses an unsupported text encoding

I am trying to work by importing the photo2cartoon project from github into my vscode.
https://github.com/kairess/photo2cartoon
But some files are not read in vscode.(model_mobilefacenet,photo2cartoon_weights.pt)
When I try to open it I get the message (the file is not displayed in the editor because it is either binary or uses an unsupported text encoding)
if i click (open anyway)
and my vscode terminal say
but the files are in the same directory
how to fix this problem

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.

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 prevent vscode as default program to run html file?

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

Visual Studio Code edit file

When I try to edit a file in visual studio code, I type the command 'code filename.ps1' and the code used to automatically open as a second tab in the editor.
Now, when I do the same thing, it opens in a new window. I have not changed anything in my settings and I can't find an associated Preference that controls this.
Anyone know exactly the default setting that I need to look at?
According to CLI Options this should work:
code -r filename.ps1
>
-r or --reuse-window
Forces opening a file or folder in the last active window.