36

I'd like to view executable file in Vim.

I used :set binary and thought that I will see only ones and zeros, but nothing changed.

How can I achieve to see only ones and zeros?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
xralf
  • 3,312
  • 45
  • 129
  • 200

2 Answers2

50

This did the trick for me:

:%!xxd -b
rhegler19
  • 613
  • 5
  • 6
43

Instead of ones and zeros, you can get an hexadecimal representation with:

:setlocal display=uhex

Also, you can get an hexadecimal dump of a buffer with:

:%!xxd

Source

jcollado
  • 39,419
  • 8
  • 102
  • 133
  • 1
    This is useful but it won't display raw file (ones and zeros) as is stored on the harddrive. It's reformated with vim. – xralf Jan 21 '12 at 16:11
  • But they write it's not possible in `vim`. Maybe hex is more convenient for real work but it's strange that vim can't display raw file. – xralf Jan 21 '12 at 16:21
  • 2
    @xralf - The thing is, 1's and 0's "format" is not that really useful at all ... so there's not that much demand for it. – Rook Jan 21 '12 at 16:37
  • Hexadecimal and Binary conversion is straighforward. Hex mode is just that, hex digits. Studying binary data or raw data is a very specific matter, just for hacking, auditing, photography, cibersecurity... few tools can do that... – Eugenio F. Martinez Pacheco Oct 22 '14 at 14:16
  • Instead of your answer, you could have given one for ones and zeros, because that's what had been asked for. – Iulian Onofrei May 08 '18 at 20:26
  • This is not an answer for the question – m4110c Sep 16 '19 at 01:44
  • The first command didn't work for me, but the second one did. – Mustapha-Belkacim Nov 03 '19 at 14:55