From 752a2498aa245be7865ad4f00e1de71d8e79ee3a Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 1 Jul 2019 11:02:51 +0200 Subject: fix neovim C-h mapping --- .vim/vimrc | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/.vim/vimrc b/.vim/vimrc index cbadca7..4ccb5f8 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -22,10 +22,10 @@ filetype plugin indent on "autocmd vimenter * NERDTree "Switch windows with keys -nmap :wincmd k -nmap :wincmd j -nmap :wincmd h -nmap :wincmd l +nmap :wincmd k +nmap :wincmd j +nmap :wincmd h +nmap :wincmd l nmap :NERDTreeToggle nmap :TlistToggle @@ -42,3 +42,46 @@ command! MakeTags !ctags -R . "Line number Highlight set nu highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE + +" Command HEXMODE +command -bar Hexmode call ToggleHex() + +" helper function to toggle hex mode +function ToggleHex() + " hex mode should be considered a read-only operation + " save values for modified and read-only for restoration later, + " and clear the read-only flag for now + let l:modified=&mod + let l:oldreadonly=&readonly + let &readonly=0 + let l:oldmodifiable=&modifiable + let &modifiable=1 + if !exists("b:editHex") || !b:editHex + " save old options + let b:oldft=&ft + let b:oldbin=&bin + " set new options + setlocal binary " make sure it overrides any textwidth, etc. + silent :e " this will reload the file without trickeries + "(DOS line endings will be shown entirely ) + let &ft="xxd" + " set status + let b:editHex=1 + " switch to hex editor + %!xxd + else + " restore old options + let &ft=b:oldft + if !b:oldbin + setlocal nobinary + endif + " set status + let b:editHex=0 + " return to normal editing + %!xxd -r + endif + " restore values for modified and read only state + let &mod=l:modified + let &readonly=l:oldreadonly + let &modifiable=l:oldmodifiable +endfunction -- cgit v1.2.3