map - Key repeats and ranges in Vim mappings -


i want define mapping in .gvimrc such if last key pressed held, triggered action repeated. specifically, want like

map <space>t :set transparency-=1 map <space>t :set transparency+=1 

for macvim, want transparency continue decreased/increased when t/t held (don't want have keep pressing spacebar).

if have suggestion nicer way adjust transparency, appreciate also.

separately, nice able able type 20 space t , have transparency decreased 20; however, when try an

e481: no range allowed. 

how enable range specification?

thanks lot.

i not sure first part of question, 20 <space> t able job:

:map <space>t :<c-u>exe "set transparency-=".v:count1<cr> 
  • with <c-u> remove line range added ex command when type 20 in normal mode.
  • with exe execute 'dynamic' vimscript.
  • v:count1 count given last normal mode command (20 in example). , if there no count given defaults 1.

for additional information see

:h v:count :h v:count1 

update:

you can omit exe using let form instead of set one:

:map <space>t :<c-u>let &transparency-=v:count1<cr> 

see :h :let-&.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -