Ⅰ. 插件描述
Vim plugin to edit binary files in a hex mode automatically.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'fidian/hexmode'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'fidian/hexmode'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'fidian/hexmode'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/fidian/hexmode
Ⅳ. 文档说明
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 addingsilent 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.
mkdir -p ~/.vim/autoload ~/.vim/bundlecurl -so ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vimecho 'call pathogen#infect()' >> ~/.vimrc
Now we can clone this repository into your ~/.vim/bundle directory.
cd ~/.vim/bundlegit 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)][cc-by-sa] 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.