Skip to content

fidian/hexmode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Vim plugin to edit binary files in a hex mode automatically.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published