Vscode: Allow to make edits to binary files

Created on 31 Jan 2016  Â·  37Comments  Â·  Source: microsoft/vscode

Hi

I am requesting that an option to open a file in the binary editor like in visual studio should be added into visual studio code

Thanks in Advance

*extension-candidate custom-editors feature-request workbench-editors

Most helpful comment

The simple fact that VSCode aborts opening a file because it doesn't recognize its format is a VSCode bug. This thread isn't requesting a feature missing from VSCode, it's describing a bug in VSCode. Only work-around I've found is to keep Notepad in my Send To menu, and the whole idea of VSCode is to offer a better alternative to Notepad, something it's thus far falling short of.

All 37 comments

Any ETA on this yet?

definitely needed feature. watching for it ..

This is the key impediment to me implementing my work in VSCode. I would dearly love to move my focus from atom to VSCode.

I looked at it. I didn't feel that it got me to where I wanted. I will revisit when I have some more bandwidth, but I was keen for the ability to write extensions that handled arbitrary file types. My processes get fairly complex and having to roll my own file parsing to get around this restriction is an added overhead.

Being limited by bandwidth I can either stick with atom and not have to worry about reading binary file types, or I move across to VSCode and add it to my todo list 😄 ... sadly (as I fell hard for VSCode) and easy choice right now.

I had a further play. The approach works ok if I am happy to explicitly point to the file from within the extension, but I want to click on the file and have VSCode hand off rendering transparently... see here.

The "else" at the bottom of vscode/src/vs/base/browser/ui/resourceviewer/resourceViewer.ts seems to preclude this as a possibility right now...

The simple fact that VSCode aborts opening a file because it doesn't recognize its format is a VSCode bug. This thread isn't requesting a feature missing from VSCode, it's describing a bug in VSCode. Only work-around I've found is to keep Notepad in my Send To menu, and the whole idea of VSCode is to offer a better alternative to Notepad, something it's thus far falling short of.

@af4jm Do you know where this check is in the source so i can take a look?

@06needhamt Look in: vscode/src/vs/base/browser/ui/resourceviewer/resourceViewer.ts

What is the status of this feature request? Will it be added to committed portion of the backlog? If so, when?

It would be nice if we could _at least_ get the filename and filepath of binary files that are open in the editor.

A use case would be opening an encrypted file using an extension.

Just give me something about the file stat infomation or anyother information. I think it is very nice.

Should VSCodeBot be added to this feature request for tracking purposes?

Please please keep this in mind as a future feature!! This is now the only reason I keep Sublime Text 2 installed. I can tell it to open any file, and then I can tell it to attempt to interpret it with a specified encoding.

Here's me using Sublime Text to look at some XMP metadata in a 1.6MB JPG file:
image

Here's an 8KB .mobileprovision file used in iOS dev that VS Code won't display either:
image

I mention these specific examples because a hexdump extension is not sufficient for these kinds of scenarios, and when this feature gets implemented for VS Code it should be more robust than just a hexdump.

Hi -

Yes, would very much like to see this capability. Have been using EditPad Pro for years and decided to get on board with a more popular editor (EditPad Pro is awesome though!). Started to like VS Code and then discovered it does _not_ support binary editing.

  • Bill

Hi -

Has anyone tried this one: https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-hexdump ?

73,836 installs and counting....so obviously people have tried. Will check out reviews etc. there.

Bill

It really would be nice to get some official word on this. The extension is cool and all, but it's a viewer, not an editor (as requested) and I share the opinion that not opening binary files is a bug. This feature should not be served by an extension.

Ideally we would get a proper binary editor, but even Notepad behavior would be better than this in the meantime.

I think hexdump is good for "real" binary-files. But if you have "mixed"-files, like the screenshots from @Ethan-VisualVocal shows, it should be possible to show all with line-feeds.

I personally have logfiles (max. 4MB), including Timestamp and transfered data from different interfaces, which can contain some binary-values.

Building upon what @Ethan-VisualVocal said. All I need is the file path to a binary file. That way I can decrypt the file before opening it into the editor using an extension I wrote myself.

To make things more interesting, some files can be opened that contain invalid data. For instance this is an image of the editor displaying a pdf file raw.
Image of editor displaying a pdf file raw

As a bootstrap to this feature you could put some plain file information about the binary file, as:
modified date, path, size, a button to open with OS editor, this simplier things that helps a lot.

Hexdump is a great extension but i think also this feature should be served from vscode not a extension.
And it would be create to have the option to open files directly in "hex-view" like the context menu entry from PSPad
grafik

IMO The hex viewer does not really need to be added to the editor. What would suffice instead is an extension hook that properly delegates handling of a binary file to an extension. Does anyone know if this is currently possible? If not, does anyone know if there is an issue open for it?
Although I agree with @ograndebe that the default view should include some basic information.

@Maxeonyx I agree. I need to decompile a binary file with an external tool and then display the source in the editor normally. As far as I can see, currently it's not possible.

If a user opens a binary file that my VSCode extension recognizes, I would like my VSCode extension to override the default view of "binary or unsupported text encoding" and show a custom view instead.

Big +1 to this. Started working on an extension to display read-only binary files of a specific type, but it's inconvenient they have to go through a text-editor first.

I'd be happy to help bring this about. (:

As mentioned above by Maxeonyx, this best describes what I'm looking for:
"What would suffice is an extension hook that properly delegates handling (reading and writing) of a binary file to an extension."
In other words: I need to de-compile a binary file with my extension and then load the source in the editor normally, on 'save' the extension should be able to handle the source and save it (compiling it) to the binary format.

Any update on this? I'm finding myself in need a hex editor and I would prefer to use VS Code if it had a proper editor. Hex Dump is lacking for anything more than viewing the file.

Can you provide binary editing and highlighting? Can it be like Synalyze It?

Shame that there's only clumsy ways to operate with binary files. And why vscode still unable to edit hexadecimal files? Universal as said but no hexadecimal files support. Viewing is almost ok. Still need adequate hex editing.

i am not vscode developer but i use it pretty much for every type of
project. this binary editing feature request is being here for a long long
time. so i guess, its not just me, there are other people who would like to
be able to edit binary files by hex values.

if vscode depends on file extensions extensively to open and recognize
files, i would suggest to keep a track of supported file types (built-in
and by extensions) and fallback by default to some hex editing view if no
known file extension is found. of course users may want to switch file type
but thats already available there.

Best wishes -
Asif Mahmud Shimon

On Thu, Oct 3, 2019 at 1:19 AM Andrew notifications@github.com wrote:

Shame that there's only clumsy ways to operate with binary files. And why
vscode still unable to edit hexadecimal files? Universal as said but no
hexadecimal files support. Viewing is almost ok. Still need adequate hex
editing.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/2582?email_source=notifications&email_token=ABLQLUVMNMJY3DR4JCNELUTQMTX5FA5CNFSM4B2AJKE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAF3WCY#issuecomment-537639691,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABLQLUUDFSMEVH7CNTUYDLLQMTX5FANCNFSM4B2AJKEQ
.

Could #82115 be a solution to this? I read the release notes for the latest version and one thing that stood out was that image preview was not an extension of its own. That surprised me, because I knew the API didn't issue onDocumentOpen events for non-text and non-PDF files, which was a major blocker for this functionality and others (like my idea for video previewer). The linked issue looks like it could allow one to associate (wildcard or at least some specific) binary extensions with a custom editor!

I would still like this to be a built-in VS Code feature as I believe editing experience is too core and there is a risk of delegating it to a 3rd party extension in that it might have a UI which doesn't feel native, support accessiblity, localization, keyboard shortcuts etc. the same way and stay behind on important developments to the core editing experience, but it's definitely better than nothing!

Just ran into a need to edit a binary file and really sad to see this isn't possible in VS Code yet, it's the first time I've needed to go back to Sublime Text in a very long time.

I'm attempting to implement this:
https://github.com/sportshead/vscode/tree/issue-2582-hex-editor

Feel free to try and help me!

It seems like this thread is conflating three entirely different use cases:

1) Ability to "on demand" allow extensions to decode on open, allow editing of the decoded content, and then re-encode on save. This supports binary formats like Applescript's (scpt) files. This functionality already exists for extensions in alternative editors like Atom. It's also necessary for existing extensions (i.e. Applescript idleberg.applescript) which suffer from this limitation.

2) Ability to open files that VSCode believes to be binary, but are believed by users to be editable. This could extend to pseudo text formats like RTF or PDF where it is possible to edit the files in a text editor to achieve desired results as long as the encoded headers of the file don't become mutated by VSCode. Allowing this through extension override and insuring VSCode doesn't mutate any displayed control characters on open/save seems a reasonable approach and can be achieved in many text editors like notepad and textedit.

3) Ability to open purely binary codes to introspect or edit, such as being repeatedly suggested via Hex Dump extension. While a great extension, it's entirely unrelated to use case #1 and #2 which seems to be the missing functionality that is actually being asked for in this thread. And no doubt having those capabilities would allow for even more functional hex extensions in the future.

Just an observation.

I believe a lot of these cases will become possible with the release of 1.4.6 and the custom editor API which is currently in a proposed state. https://code.visualstudio.com/api/extension-guides/custom-editors. This milestone does currently contain a hex editor implementation utilizing that API that I will be working on in the next couple of months. I welcome everyone's feedback to what they would like to see in a custom hex editor.

The hex editor extension adds support for both viewing and editing binary files

Give it a try. If there any features you think are missing, please open new issues against that extension

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DovydasNavickas picture DovydasNavickas  Â·  3Comments

shanalikhan picture shanalikhan  Â·  3Comments

omidgolparvar picture omidgolparvar  Â·  3Comments

biij5698 picture biij5698  Â·  3Comments

philipgiuliani picture philipgiuliani  Â·  3Comments