vim - How to merge menu entries for normal and visual mode? -


i have many menu entries these:

nnoremenu <silent> 94.015.10 &mymenu.test\   :call test("%","keyw2",keyw3")<cr> vnoremenu <silent> 94.015.10 &mymenu.test\   :<c-u>call test("'<,'>","keyw2",keyw3")<cr> 

one normal mode 'nnoremenu' and
1 visual mode 'vnoremenu'

with same keywords except first 1 ("%","'<,'>")

is there no way merge them together?

p.e. possible this:

an <silent> 94.015.10 &mymenu.test\   :call test("","keyw2",keyw3")<cr> 

and check within function if normal mode or visual mode active?

when use :an, visual mode automatically aborted via <c-c>. means there no way retrieve mode more (and <c-u> prefix not necessary); if need mode information, have keep 2 different menu definitions.

if reduce code duplication, have utilize other means, e.g. metaprogramming (that is, building , :executing menu definition commands in loop).

edit: on request, here's example of how tackle avoid duplication:

for [mode, range] in [['n', '%'], ['v', "'<,'>"]]     execute printf('%snoremenu <silent> 94.015.10 &mymenu.test\   :call test(%s,"keyw2","keyw3")<cr>', mode, string(range)) endfor 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -