Skip to content
Search

Vim:Plugin:Quickui

lastmod 2024-11-05created 2024-11-051 edits

The missing UI extensions for Vim 9 (and NeoVim)

How to keep the selected range when switching the top menu

INFORMATION

This is a GPT answer. Needs verification.

To keep the selected range when switching menus in the quickui.vim plugin, try the following approach. It works by saving and restoring the range.

  • Before switching menus, save the currently selected range with the '< and '> marks.
  • After switching menus, reselect the saved range to restore it.

Below is a basic code example that does this.

" Define a function to save and restore the selection range
function! PreserveSelectionOnMenuSwitch()
  " Save the selected range into variables
  let l:old_start = getpos("'<")
  let l:old_end = getpos("'>")

  " Perform your menu switch or action here
  " Example: call quickui#switch() or any other menu command

  " Restore the previously selected range
  call setpos("'<", l:old_start)
  call setpos("'>", l:old_end)
  normal! gv
endfunction

This function saves the selection range before the menu switch and restores the saved range as the selection after the menu switch. The gv command restores the last visual selection range.

After adding the code above to your .vimrc file, run the :call PreserveSelectionOnMenuSwitch() command when switching menus and the range is kept. You can also map it together with quickui.vim menu commands.

See also

Favorite site

author Zer0 sitemap