I need to make a report about investment everyday. It requires a lot of changes of the sign of figures. (from -
to +
or from +
to -
)
Is there a simple way to overload (extend) the ~
command (switch case) with such a toggle function?
I would do:
function! ExtendToggle()
let char = getline(line('.'))[col('.')-1]
if char == '-'
return 'r+l'
elseif char == '+'
return 'r-l'
else
return '~'
endif
endfunction
nnoremap <expr> ~ ExtendToggle()
<space>
by l
since for a number of us <space>
is the leader key)
Commented
Mar 1 at 10:42
<space>
should be OK because it is protected by nnoremap
. The space will just be a space, not a leader or any other mapping.
<leader>
are only used in mapping and the nnoremap
is ignoring the mapping so indeed it should be fine (to be sure I have tested) :-)
Commented
Mar 1 at 19:06