~gpanders/dotfiles

ref: fe3c3c6d5c840bb713a7160d9c2d0b7f5885ea99 dotfiles/vim/.vim/plugin/binary.vim -rw-r--r-- 679 bytes
fe3c3c6dGreg Anders Clean up plugins and use more consistent conventions 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
" Improved editing of binary files
" This makes vim a slightly more tolerable hex editor, although there are
" still better options out there
" Most of the magic happens in the xxd filetype plugin, not here
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-24

augroup plugin.binary
  autocmd!
  autocmd BufReadPost  * if &bin | %!xxd
  autocmd BufReadPost  * set ft=xxd
  autocmd BufReadPost  * endif
  autocmd BufWritePre  * if &bin | %!xxd -r
  autocmd BufWritePre  * endif
  autocmd BufWritePost * if &bin | %!xxd
  autocmd BufWritePost * set nomod | endif
augroup END

" Delete the augroup if not in binary mode
au VimEnter * if !&binary | au! plugin.binary | endif