Questions tagged [binary-file]

Questions about editing non-text files.

Filter by
Sorted by
Tagged with
0 votes
0 answers
35 views

Adding new line characters after a specific amount of bytes

I'd like to add new line characters after every specific number of bytes in binary mode. I tried this script but the repetition count depends on the number of characters not bytes. Like when there is ...
user avatar
  • 101
1 vote
1 answer
41 views

How to enter linefeed in binary mode?

Trying to find a linefeed within a binary file using vim -b, but any attempt at entering that byte value (e.g. control-v control-j, control-v 010, control-v u000a) turns into a NUL (^@) instead. I've ...
user avatar
  • 196
0 votes
0 answers
35 views

Command (e.g. `g++`) does not point to the same binary when run from the terminal or from (neo)vim

I have NVIM v0.4.3 on macOS Mojave version 10.14.6 I have different version of g++ compilers on my machine and made the following alias in my .zshrc file: alias g++="/usr/local/bin/g++-9" ...
user avatar
  • 139
1 vote
1 answer
119 views

hex mode crashes after saving file

I have a a.out file from "hello world" in c: #include <stdio.h> #include <stdlib.h> int main(){ printf("hello world\n"); } Which I can see in hexdump (file a.out) ...
user avatar
3 votes
1 answer
1k views

vim hex editor with xxd not working as intended

I'm trying to use vim as a hex editor. I am using the %!xxd / %!xxd -r method, and it worked fine until I tried a some bytes that didn't work as expected : 00000000: 1337 6161 6161 6161 6161 6161 ...
user avatar
3 votes
1 answer
315 views

How to list content of nested jars

Suppose, I have a .jar file a.jar, which I can view via vim a.jar, giving a list of the content like: a1.txt a2.txt b.jar I can press enter and load the content of each file; however, for .jars ...
user avatar
  • 131
2 votes
1 answer
305 views

Why does Vi change the size of my .bin file?

I have a .bin file which has a size of 8192. If I open the file in Vi, then use :wq without making any changes, the file size becomes 8193. What's happening? It's a HEX file if that makes any ...
user avatar
1 vote
0 answers
171 views

Hide binary portion in mixed text-binary file

I have a self-extracting "archive" generated by Makeself tool, which is essentially a shell script with a large binary blob in inside. What I want is to view only text part of the file, while hiding ...
user avatar
3 votes
1 answer
954 views

Why is `%!xxd -r` result wrong while `xxd -r` from console with the same input works correctly?

I have the following file named asterix: 0000000: 15 00 1f c1 13 31 49 80 02 64 01 08 42 48 ef 28 0000010: 2d cd 0c 02 00 07 f1 e9 1b 04 63 30 c7 08 20 When I open this file in vim, I ...
user avatar
  • 465
9 votes
1 answer
1k views

How to open *.dia files as *.gz files?

vim proj.dia gives binary data. If renamed, vim opens it by unzipping: $ mv proj.dia proj.dia.gz $ vim proj.dia.gz How to make the .dia act the same as .gz?
user avatar
  • 205
1 vote
1 answer
2k views

How to edit a readonly zip file?

I tried to edit a zip file and change its content using the following commands :set modifiable :%s/xxA/..\//g :x! But it returned the following error W10: Warning: Changing a readonly file 55 ...
user avatar
7 votes
1 answer
3k views

How to force Vim to open given file as another filetype? (e.g. .txt.gz?)

Problem: I have .glabels generated files, which are gzipped xml. When I rename file to have suffix .xml.gz, then VIM properly recognizes file and it's editable, human readable xml. After edit I have ...
user avatar
3 votes
1 answer
17k views

Where is xxd in Windows gvim?

Does it exist? Is it Linux only? Do I have to install it? According to this, it's :!xxd to convert the file to hex, and it's :!xxd -r to convert it back again.
user avatar
  • 3,141
4 votes
1 answer
254 views

How do I perform a replacement on all files in a zip archive?

I have openend a zip archive with vim (zip.vim v27) and now want to replace a string in all files contained in the archive. I'm aware that I could manually open all files in buffers and then do bufdo ...
user avatar
  • 755
14 votes
2 answers
3k views

How to get the current byte offset in whole file

I saw that you could display the current byte offset in the statusline using %o, but I found no function or command which does the same. Is there a way of getting the current byte offset ...
user avatar
11 votes
2 answers
2k views

Go to X bytes from here

How can I move X bytes forward, starting from the current cursor location (including line breaks)? [count]go could be used to move forward X bytes from the start of the buffer. I tried Shift + V, G, [...
user avatar
  • 361
2 votes
2 answers
1k views

How to make vim to uncompress archive formats?

In here it's suggested that vim can do automatic uncompression of gzip/zip files (including other formats) and it's something built-in. How do I open compressed file then? Sample scenario: curl ...
user avatar
  • 16.8k
4 votes
2 answers
1k views

How to check if file is binary?

Is there any way to determine within Vim that the file which I'm editing is either in text or binary format? For example: vim http://example.com/ vs: vim http://cdn.sstatic.net/vi/img/apple-touch-...
user avatar
  • 16.8k
23 votes
3 answers
14k views

Jumping to a byte offset, and displaying position as byte offset

How can I move the cursor to the nth byte in the buffer? How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: ...
user avatar
  • 8,819
148 votes
2 answers
284k views

How can I use Vim as a hex editor? [duplicate]

Is there a neat way I can view binary files as hex in Vim, and save it back to binary from the hex?
user avatar
  • 1,633
18 votes
2 answers
6k views

How to tell vim not to try to unzip a file

I'm trying to open an .xlsx file in Vim, but got an error saying: ***error*** (zip#Browse) unzip not available on your system I know it's a binary file, but I want to do some checksums and ...
user avatar
  • 737
107 votes
5 answers
117k views

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
user avatar
  • 2,648