visual mode popup menu ?

24 views
Skip to first unread message

M Kelly

unread,
Apr 26, 2020, 8:37:42 PM4/26/20
to vim_use
Hi,

Is there a way to be in visual mode with some text highlighted and popup a menu and keep the highlighted text during and after the popup menu ?

thx,
-m

Andy Wokula

unread,
Apr 30, 2020, 11:52:03 AM4/30/20
to vim...@googlegroups.com
I would think it could make sense for some popup menu entries, but not all ...
how about an example?

You can override specific menu entries.

For what to override, see
:vmenu PopUp
:split +/PopUp/ $VIMRUNTIME/menu.vim

For example, original:
:vnoremenu 1.30 PopUp.&Copy "+y
modified (see vimrc below) (do not modify in-place):
:vnoremenu PopUp.&Copy "+ygv

" ------------------------------------------------
" in the vimrc ... more work for delayed execution
augroup KellyVimrc
augroup END

au! KellyVimrc VimEnter * call s:OverrideMenu()

func! s:OverrideMenu()
vnoremenu PopUp.&Copy "+ygv
" ... more ...
endfunc

"" for reloading ...
"if !has('vim_starting')
" doau <nomodeline> KellyVimrc VimEnter
"endif


--
Andy

M Kelly

unread,
Apr 30, 2020, 8:31:27 PM4/30/20
to vim_use
Andy, hi again

I was thinking of something like -

    call popup_menu(g:menulist, #{ title: 'MyMenuTitle:', filter: 'MyFilter', callback: 'MyCallback' })

I would highlight some code and then press a key to trigger the popup menu and select some option from that menu,
but when the menu pops I didn't want to lose the visual highlighting.
Perhaps I can do something like exe normal gv as part of the popup ??

I wasn't thinking of vmenu - is that available at the cursor location ?  I will read up on it.

take care,
-m

M Kelly

unread,
Apr 30, 2020, 8:45:31 PM4/30/20
to vim_use
Andy, hi

I think it does work if I add the exe normal gv in the popup func.
cool!

thx,
-m

Reply all
Reply to author
Forward
0 new messages