vim-deadc0de : Hex editor for Vim. It uses UNIX utility xxd for conversion.
script karma |
Rating 8/2,
Downloaded by 661 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Artem Korotchenko |
|
script type |
ftplugin |
|
description |
- Open hex editor by pressing <Shift-F6>. (Of course, you can set your own
keybinding.) It does buffer conversion.
- When you complete editing, convert to plain text/blob back by pressing
<Shift-F6>.
- Vim almost supports hex edition, but it lacks of very important features.
This plugin updates ASCII block of edited blob while you're changing the
HEXes.
- Reverse action is supported too. Edit the ASCII block and it changes the
HEX.
But be sure the edited ASCII line doesn't contain any unprintable
characters, i. e. control sequences. Such characters are presented by
dotas (.).
- The plugin highlights the currently selected byte in HEX block and the
corresponding character in ASCII block.
- Reverse is done too.
- Switch between them by entering "gs". (Again, you can set your own
keybinding.)
- Data protection prevents you from breaking a hex file.
Assume you has entered "x" character, which is not hexadecimal character.
Buffer would be restored immidiately.
- Data protection can be toggled by "gp". (Or another keybinding.)
- xxd utility supports only 7-bit ASCII table encoding that outputs in ASCII
block. (Not all special characters work even so.).
Extended encodings which use eight bit are not supported by xxd.
But this plugin adds support of all printable characters. (One-byte encodings
Latin 1, KOI8-R, CP1251, CP866 are tested; One-byte characters from UTF-8 are
tested.)
- Work with newlines accurately.
Please, set binary mode and turn off EOL if you are editing an blob.
- Open hexadecimal editor in a new buffer. (Due to safety.)
It is saved to temporary directory, usually, /tmp/.
- Some options allow to tune the plugin. (Number of them will increase in
future.) |
|
install details |
Install xxd.
Install Perl interpreter and Iconv binding for it:
$ sudo apt install xxd
$ sudo apt install perl libtext-iconv-perl
Copy the plugin to your Vim directory (usually, ~/.vim/):
+ doc/vim-deadc0de.txt
+ plugin/vim-deadc0de.vim
+ ftplugin/xxd.vim
Rebuild the Vim documentation:
:helptags ~/.vim/doc/
Then add to your .vimrc:
" General behavior
filetype on " Enable file detection
filetype plugin on " Enable loading the plug-in files for specific file types
syntax on " Enable syntax highlighting
" Load hex editor
runtime plugins/vim-deadc0de.vim
" <Shift-F6> Convert to hex / convert back using vim-deadc0de
noremap <S-F6> :HexConvert<CR>
imap <S-F6> <C-O><S-F6>
" Toggle hex file protection by entering "gp".
" This protection is also controlled by g:deadc0de_protection.
map gp <Plug>hexprotectiontoggle
" Move cursor to the corresponding ASCII character (and then back) by entering
" "gs"
map gs <Plug>hexblockscycle
(You can use any other available keybindings for this purpose.)
vim-deadc0de is filetype plugin (ftplugin), not syntax plugin.
But it works in conjunction with xxd.vim syntax plugin by Charles E. Campbell.
xxd.vim should be already installed in your system, check it:
$ ls /usr/share/vim/vim*/syntax/xxd.vim # Debian- and Ubuntu-based distros path |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 3.17.141.114
|