Skip to content
Vim plugin to edit binary files in a hex mode automatically.
Vim script Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc add g:hexmode_xxd_options Oct 29, 2018
plugin
test Removing autodetection mode. Dec 4, 2017
.gitignore Initial commmit Sep 13, 2012
.travis.yml Enabling automatic builds Oct 17, 2017
README.md

README.md

Hexmode - Hex editing in Vim

Ever need a hex editor? Tired of installing ncurses-hexedit, hexedit, or maybe even using an od script to format some binary file as hex just so you can see if there are null characters at the end of the file? Fret no longer!

Thankfully, there is a wonderful wiki page that illustrated not only how to use xxd to filter files to/from hex, but it also provided a great function, called ToggleHex. On top of that, there are buffer reading and writing hooks so using vim to edit a binary file will automatically edit it as hex.

Also, on that wiki page, it mentions how to avoid getting the "Press ENTER or type command to continue" message that would normally show up. By adding silent in a couple places, the ToggleHex function now operates quietly. Fantastic!

So now I put out this repository so others can easily grab the plugin as just a single file instead of copying and pasting the bits from the webpage and also figuring out where to put this magical silent command.

Installation

First, install the Pathogen plugin if you don't already have it. Adding other plugins by using Pathogen makes things much easier. Careful: the second command is quite long.

  1. mkdir -p ~/.vim/autoload ~/.vim/bundle
  2. curl -so ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
  3. echo 'call pathogen#infect()' >> ~/.vimrc

Now we can clone this repository into your ~/.vim/bundle directory.

  1. cd ~/.vim/bundle
  2. git clone https://github.com/fidian/hexmode.git

Usage

Simply editing a file in binary mode, e.g.,

vim -b some_file.jpg

will open it in hex mode.

Also, you can use :Hexmode to switch between hex editing and normal editing.

Use the g:hexmode_patterns flag to automatically open specific file patterns in hex mode. E.g.,

let g:hexmode_patterns = '*.bin,*.exe,*.dat,*.o'

Use the g:hexmode_xxd_options flag to pass options to xxd. E.g.,

let g:hexmode_xxd_options = '-g 1'

Credits and License

Tyler Akins (the "fidian" guy at GitHub) did not write this. Mad props go out to Fritzophrenic for fulfilling this need so completely. Also, look at the commit log for other contributions that were received after the plugin was released on GitHub.

The plugin is under a Creative Commons Attribution-Share Alike License 3.0 (Unported) because the original post was under that license. Make sure that all code contributions are also under this license. Officially, here is the notice:

This vim plugin uses material from the "Improved hex editing" article on the Vim Tips Wiki at Wikia and is licensed under the Creative Commons Attribution-Share Alike License.

Alternatives and Enhancements

You might want to look at hexman.vim for additional functionality. Also, I'd be happy to accept pull requests if there are some improvements that you would be willing to submit to the project.

You can’t perform that action at this time.