I am experimenting with default key mappings and am considering remapping the g
key entirely. But first I would like to turn off all the existing mappings that g
has. For now I am using this kind of hack:
" disable all g maps
let g:netrw_nogx = 1 " allows disabling gx
let s:chars1 = map(range(char2nr('a'), char2nr('x')), 'nr2char(v:val)')
let s:chars2 = map(range(char2nr('A'), char2nr('Z')), 'nr2char(v:val)')
let s:chars = s:chars1 + s:chars2
let s:chars = s:chars+['0','1','2','3','4','5','6','7','8','9','+','-','=','_']
let s:chars = s:chars+['~','`','!','@','#','$','%','^','&','*','(',')','/','?']
let s:chars = s:chars+['[',']','{','}','\','\|',':',';','"',"'",'<',">",'.',',']
for char in s:chars
execute 'noremap g' . char . ' <nop>'
endfor
But this is very messy and g<ctrl-_>
maps are still left in.
Is there some cleaner way to accomplish this?
<nop>
? Also, I agree with Christian that is probably the best way to do it.gq
,gU
, etc whileunmap
would be useful to delete mappings created by the user. What I was wondering is, why does one need to disable all of these built-in commands?g
prefix for "goto" commands. I.E.gg
goes to topG
goes to bottom,gf
goes to file,gb
andgB
would traverse buffers, etc. No big reason to disable all g prefix maps, but it would help in a sense that I would be sure pressingg
will put me into agoto
context and would not do something else by accident.