From c61240c532e531980af4f56e81652760377e6c11 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 12 Apr 2018 08:19:29 +0200 Subject: [PATCH] Make Hex command more robust Hex command now infers more meaning from context. --- vimrc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vimrc b/vimrc index 6c9ee24..d0b1d0e 100644 --- a/vimrc +++ b/vimrc @@ -283,24 +283,22 @@ function! s:hex(...) else let l:args = [] end - if !exists("b:hex") + if &filetype != "xxd" silent exec '%!xxd '.join(l:args, " ") - let b:hex = 1 - let b:prev_filetype = &filetype - let &filetype = "xxd" + set filetype=xxd nnoremap i i echo "A witch turned your file into a hexadecimal toad!" else nunmap i silent exec '%!xxd -r '.join(l:args, " ") - unlet b:hex - let &filetype = b:prev_filetype - unlet b:prev_filetype + filetype detect echo "The witch turned your file back into binary data" end endfunction command! -nargs=* Hex call hex() +" === GIT STUFF === " + function! s:uncommitted(...) if a:0 let l:commit = a:1