Skip to content

Commit

Permalink
add g:hexmode_xxd_options
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk committed Oct 29, 2018
1 parent fe9d702 commit 8aca89e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions doc/hexmode.txt
Expand Up @@ -57,6 +57,12 @@ The |g:hexmode_autodetect| flag may be enabled to allow autodetection of binary
files based on the file contents. The flag is off by default. E.g.,
>
let g:hexmode_autodetect = 1
<
*g:hexmode_xxd_options*
The |g:hexmode_xxd_options| flag may be set to specify additional options
for the xxd program, E.g.,
>
let g:hexmode_xxd_options = '-g 1'
<
=====================================================================
DEVELOPMENT *HexmodeDevelopment*
Expand Down
11 changes: 7 additions & 4 deletions plugin/hexmode.vim
Expand Up @@ -14,6 +14,9 @@ let g:loaded_hexmode_plugin = 1
" auto hexmode file patterns, default none
let g:hexmode_patterns = get(g:, 'hexmode_patterns', '')

" auto hexmode xxd options, default none
let g:hexmode_xxd_options = get(g:, 'hexmode_xxd_options', '')

" ex command for toggling hex mode - define mapping if desired
command -bar Hexmode call ToggleHex()

Expand All @@ -34,7 +37,7 @@ function ToggleHex()
" set status
let b:editHex=1
" switch to hex editor
silent %!xxd
silent exe "%!xxd " . g:hexmode_xxd_options
" set new options
let &l:bin=1 " make sure it overrides any textwidth, etc.
let &l:ft="xxd"
Expand All @@ -43,7 +46,7 @@ function ToggleHex()
let &l:ft = b:oldft
let &l:bin = b:oldbin
" return to normal editing
silent %!xxd -r
silent exe "%!xxd -r " . g:hexmode_xxd_options
" set status
let b:editHex=0
endif
Expand Down Expand Up @@ -119,7 +122,7 @@ if has("autocmd")
\ let b:oldro=&l:ro | let &l:ro=0 |
\ let b:oldma=&l:ma | let &l:ma=1 |
\ undojoin |
\ silent exe "%!xxd -r" |
\ silent exe "%!xxd -r " . g:hexmode_xxd_options |
\ let &l:ma=b:oldma | let &l:ro=b:oldro |
\ unlet b:oldma | unlet b:oldro |
\ let &l:ul = &l:ul |
Expand All @@ -131,7 +134,7 @@ if has("autocmd")
\ let b:oldro=&l:ro | let &l:ro=0 |
\ let b:oldma=&l:ma | let &l:ma=1 |
\ undojoin |
\ silent exe "%!xxd" |
\ silent exe "%!xxd " . g:hexmode_xxd_options |
\ exe "setlocal nomod" |
\ let &l:ma=b:oldma | let &l:ro=b:oldro |
\ unlet b:oldma | unlet b:oldro |
Expand Down

0 comments on commit 8aca89e

Please sign in to comment.