System:
nvim verison 0.4.4
Debian-11, KDE, Konsole
I’m unable to achieve the mouse behavior stated in the nvim documentation.
Desired mouse behavior in nvim (terminal nvim, not GUI nvim-qt):
- left-click mouse to “place cursor” at current mouse position
- left-drag mouse to “select text”
- right-click mouse to “popup” a menu containing “Copy” and “Paste”
- selecting popup menu “Copy” will copy selected text into system clipboard
- selecting popup menu “Paste” will copy system clipboard at current cursor position
(I’ll skip configuring the clipboard for now (":set clipboard+=unnamedplus") and focus only on configuring the mouse).
From reading the nvim documentation, this mouse behavior appears to be achieved by:
:behave mswin
or
:set mousemodel=popup
Unfortunately, when I tested these options (“init.vim” contains only “:set mousemodel=popup” or “:behave mswin”),
- left-click mouse FAILS to “place cursor” at current the mouse position.
- In fact, left-click mouse has NO effect on the cursor position.
Next, the nvim documentation gave another option:
:set mouse=a
Unfortunately, when I tested this option (“init.vim” contains only “:set mouse=a”), I’m unable to “Copy”:
- left-click mouse places the cursor. ← GOOD!
- left-drag mouse selects text. ← GOOD!
- SHIFT-right-click produces popup menu ← NOT right-click, but instead SHIFT-right-click
- But popup menu lacks “Copy” option ← “Paste” present, but “Copy” missing
Finally, I tried combinations of these options in “init.vim”, but they all failed in some manor.
For example (one of many combinations tried):
set mouse=a "left-click mouse places cursor. SHIFT-right-click yields popup menu, but lacks "Copy"
behave mswin "left-click mouse FAILS to place cursor.
"behave xterm "left-click mouse FAILS to place cursor.
set mousemodel=popup "left-click mouse FAILS to place cursor.
"set mousemodel=extend "left-click mouse FAILS to place cursor.
What am I doing wrong?
Any help appreciated.
P.S. For reference, below are the nvim documentation pages for these mouse options:
--------------------------------------------------------------------------------
*:behave* *:be*
:be[have] {model} Set behavior for mouse and selection. Valid
arguments are:
mswin MS-Windows behavior
xterm Xterm behavior
Using ":behave" changes these options:
option mswin xterm ~
'selectmode' "mouse,key" ""
'mousemodel' "popup" "extend"
'keymodel' "startsel,stopsel" ""
'selection' "exclusive" "inclusive"
--------------------------------------------------------------------------------
'mousemodel' 'mousem'
'mousemodel' 'mousem' string (default "extend")
global
Sets the model to use for the mouse. The name mostly specifies what
the right mouse button is used for:
extend Right mouse button extends a selection. This works
like in an xterm.
popup Right mouse button pops up a menu. The shifted left
mouse button extends a selection. This works like
with Microsoft Windows.
popup_setpos Like "popup", but the cursor will be moved to the
position where the mouse was clicked, and thus the
selected operation will act upon the clicked object.
If clicking inside a selection, that selection will
be acted upon, i.e. no cursor move. This implies of
course, that right clicking outside a selection will
end Visual mode.
Overview of what button does what for each model:
mouse extend popup(_setpos)
left click place cursor place cursor
left drag start selection start selection
shift-left search word extend selection
right click extend selection popup menu (place cursor)
right drag extend selection -
middle click paste paste
--------------------------------------------------------------------------------
*'mouse'* *E538*
'mouse' string (default "")
global
Enables mouse support. For example, to enable the mouse in Normal mode
and Visual mode: >
:set mouse=nv
<
To temporarily disable mouse support, hold the shift key while using
the mouse.
Mouse support can be enabled for different modes:
n Normal mode
v Visual mode
i Insert mode
c Command-line mode
h all previous modes when editing a help file
a all previous modes
r for |hit-enter| and |more-prompt| prompt
Left-click anywhere in a text buffer to place the cursor there. This
works with operators too, e.g. type |d| then left-click to delete text
from the current cursor position to the position where you clicked.
Drag the |status-line| or vertical separator of a window to resize it.
If enabled for "v" (Visual mode) then double-click selects word-wise,
triple-click makes it line-wise, and quadruple-click makes it
rectangular block-wise.
For scrolling with a mouse wheel see |scroll-mouse-wheel|.
Note: When enabling the mouse in a terminal, copy/paste will use the
"* register if possible. See also 'clipboard'.
Related options:
'mousefocus' window focus follows mouse pointer
'mousemodel' what mouse button does which action
'mousehide' hide mouse pointer while typing text
'selectmode' whether to start Select mode or Visual mode
--------------------------------------------------------------------------------