Skip to content

Commit 5b41899

Browse files
committed
patch 8.1.2226: cannot use system copy/paste in non-xterm terminals
Problem: Cannot use system copy/paste in non-xterm terminals. Solution: Instead of setting 'mouse' to "a" set it to "nvi" in defaults.vim.
1 parent 5241057 commit 5b41899

4 files changed

Lines changed: 32 additions & 8 deletions

File tree

runtime/defaults.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ inoremap <C-U> <C-G>u<C-U>
7575
7676
" In many terminal emulators the mouse works just fine. By enabling it you
7777
" can position the cursor, Visually select and scroll with the mouse.
78+
" Only xterm can grab the mouse events when using the shift key, for other
79+
" terminals use ":", select text and press Esc.
7880
if has('mouse')
79-
set mouse=a
81+
if &term =~ 'xterm'
82+
set mouse=a
83+
else
84+
set mouse=nvi
85+
endif
8086
endif
8187

8288
" Switch syntax highlighting on when the terminal has colors or when using the

runtime/doc/options.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,12 +5191,11 @@ A jump table for the options with a short description can be found at |Q_op|.
51915191

51925192
*'mouse'* *E538*
51935193
'mouse' string (default "", "a" for GUI, MS-DOS and Win32,
5194-
set to "a" in |defaults.vim|)
5194+
set to "a" or "nvi" in |defaults.vim|)
51955195
global
5196-
Enable the use of the mouse. Only works for certain terminals
5197-
(xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
5198-
sysmouse and Linux console with gpm). For using the mouse in the
5199-
GUI, see |gui-mouse|.
5196+
Enable the use of the mouse. Works for most terminals (xterm, MS-DOS,
5197+
Win32 |win32-mouse|, QNX pterm, *BSD console with sysmouse and Linux
5198+
console with gpm). For using the mouse in the GUI, see |gui-mouse|.
52005199
The mouse can be enabled for different modes:
52015200
n Normal mode and Terminal modes
52025201
v Visual mode
@@ -5207,7 +5206,15 @@ A jump table for the options with a short description can be found at |Q_op|.
52075206
r for |hit-enter| and |more-prompt| prompt
52085207
Normally you would enable the mouse in all five modes with: >
52095208
:set mouse=a
5210-
< When the mouse is not enabled, the GUI will still use the mouse for
5209+
< If your terminal can't overrule the mouse events going to the
5210+
application, use: >
5211+
:set mouse=nvi
5212+
< The you can press ":", select text for the system, and press Esc to go
5213+
back to Vim using the mouse events.
5214+
In |defaults.vim| "nvi" is used if the 'term' option is not matching
5215+
"xterm".
5216+
5217+
When the mouse is not enabled, the GUI will still use the mouse for
52115218
modeless selection. This doesn't move the text cursor.
52125219

52135220
See |mouse-using|. Also see |'clipboard'|.

runtime/doc/term.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,21 @@ jump to tags).
746746
Whether the selection that is started with the mouse is in Visual mode or
747747
Select mode depends on whether "mouse" is included in the 'selectmode'
748748
option.
749-
749+
*terminal-mouse*
750750
In an xterm, with the currently active mode included in the 'mouse' option,
751751
normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
752752
pressed go to the xterm. With the currently active mode not included in
753753
'mouse' all mouse clicks go to the xterm.
754754

755+
For terminals where it is not possible to have the mouse events be used by the
756+
terminal itself by using a modifier, a workaround is to not use mouse events
757+
for Vim in command-line mode: >
758+
:set mouse=nvi
759+
Then to select text with the terminal, use ":" to go to command-line mode,
760+
select and copy the text to the system, then press Esc.
761+
762+
Another way is to temporarily use ":sh" to run a shell, copy the text, then
763+
exit the shell. 'mouse' can remain set to "a" then.
755764
*xterm-clipboard*
756765
In the Athena and Motif GUI versions, when running in a terminal and there is
757766
access to the X-server (DISPLAY is set), the copy and paste will behave like

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2226,
744746
/**/
745747
2225,
746748
/**/

0 commit comments

Comments
 (0)