Patch 8.1.2226

19 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 27, 2019, 1:51:49 PM10/27/19
to vim...@googlegroups.com

Patch 8.1.2226
Problem: Cannot use system copy/paste in non-xterm terminals.
Solution: Instead of setting 'mouse' to "a" set it to "nvi" in defaults.vim.
Files: runtime/defaults.vim, runtime/doc/term.txt,
runtime/doc/options.txt


*** ../vim-8.1.2225/runtime/defaults.vim 2019-02-18 21:31:58.224542949 +0100
--- runtime/defaults.vim 2019-10-27 18:41:21.544060260 +0100
***************
*** 75,82 ****

" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
if has('mouse')
! set mouse=a
endif

" Switch syntax highlighting on when the terminal has colors or when using the
--- 75,88 ----

" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
+ " Only xterm can grab the mouse events when using the shift key, for other
+ " terminals use ":", select text and press Esc.
if has('mouse')
! if &term =~ 'xterm'
! set mouse=a
! else
! set mouse=nvi
! endif
endif

" Switch syntax highlighting on when the terminal has colors or when using the
*** ../vim-8.1.2225/runtime/doc/term.txt 2019-10-12 21:08:37.002660427 +0200
--- runtime/doc/term.txt 2019-10-27 18:31:06.334311963 +0100
***************
*** 746,757 ****
Whether the selection that is started with the mouse is in Visual mode or
Select mode depends on whether "mouse" is included in the 'selectmode'
option.
!
In an xterm, with the currently active mode included in the 'mouse' option,
normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
pressed go to the xterm. With the currently active mode not included in
'mouse' all mouse clicks go to the xterm.

*xterm-clipboard*
In the Athena and Motif GUI versions, when running in a terminal and there is
access to the X-server (DISPLAY is set), the copy and paste will behave like
--- 746,766 ----
Whether the selection that is started with the mouse is in Visual mode or
Select mode depends on whether "mouse" is included in the 'selectmode'
option.
! *terminal-mouse*
In an xterm, with the currently active mode included in the 'mouse' option,
normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
pressed go to the xterm. With the currently active mode not included in
'mouse' all mouse clicks go to the xterm.

+ For terminals where it is not possible to have the mouse events be used by the
+ terminal itself by using a modifier, a workaround is to not use mouse events
+ for Vim in command-line mode: >
+ :set mouse=nvi
+ Then to select text with the terminal, use ":" to go to command-line mode,
+ select and copy the text to the system, then press Esc.
+
+ Another way is to temporarily use ":sh" to run a shell, copy the text, then
+ exit the shell. 'mouse' can remain set to "a" then.
*xterm-clipboard*
In the Athena and Motif GUI versions, when running in a terminal and there is
access to the X-server (DISPLAY is set), the copy and paste will behave like
*** ../vim-8.1.2225/runtime/doc/options.txt 2019-10-27 05:12:38.280773740 +0100
--- runtime/doc/options.txt 2019-10-27 18:37:59.472843478 +0100
***************
*** 5192,5203 ****

*'mouse'* *E538*
'mouse' string (default "", "a" for GUI, MS-DOS and Win32,
! set to "a" in |defaults.vim|)
global
! Enable the use of the mouse. Only works for certain terminals
! (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
! sysmouse and Linux console with gpm). For using the mouse in the
! GUI, see |gui-mouse|.
The mouse can be enabled for different modes:
n Normal mode and Terminal modes
v Visual mode
--- 5191,5201 ----

*'mouse'* *E538*
'mouse' string (default "", "a" for GUI, MS-DOS and Win32,
! set to "a" or "nvi" in |defaults.vim|)
global
! Enable the use of the mouse. Works for most terminals (xterm, MS-DOS,
! Win32 |win32-mouse|, QNX pterm, *BSD console with sysmouse and Linux
! console with gpm). For using the mouse in the GUI, see |gui-mouse|.
The mouse can be enabled for different modes:
n Normal mode and Terminal modes
v Visual mode
***************
*** 5208,5214 ****
r for |hit-enter| and |more-prompt| prompt
Normally you would enable the mouse in all five modes with: >
:set mouse=a
! < When the mouse is not enabled, the GUI will still use the mouse for
modeless selection. This doesn't move the text cursor.

See |mouse-using|. Also see |'clipboard'|.
--- 5206,5220 ----
r for |hit-enter| and |more-prompt| prompt
Normally you would enable the mouse in all five modes with: >
:set mouse=a
! < If your terminal can't overrule the mouse events going to the
! application, use: >
! :set mouse=nvi
! < The you can press ":", select text for the system, and press Esc to go
! back to Vim using the mouse events.
! In |defaults.vim| "nvi" is used if the 'term' option is not matching
! "xterm".
!
! When the mouse is not enabled, the GUI will still use the mouse for
modeless selection. This doesn't move the text cursor.

See |mouse-using|. Also see |'clipboard'|.
*** ../vim-8.1.2225/src/version.c 2019-10-27 05:12:38.288773701 +0100
--- src/version.c 2019-10-27 18:33:11.813891541 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2226,
/**/

Bram Moolenaar

unread,
Oct 27, 2019, 2:00:16 PM10/27/19
to vim...@googlegroups.com, Bram Moolenaar

I wrote:

> Patch 8.1.2226
> Problem: Cannot use system copy/paste in non-xterm terminals.
> Solution: Instead of setting 'mouse' to "a" set it to "nvi" in defaults.vim.
> Files: runtime/defaults.vim, runtime/doc/term.txt,
> runtime/doc/options.txt

Please review this change. It's supposed to help for those users who
get the default setup, thus sourcing defaults.vim. Some users
complained that this makes it impossible to select text using the system
clipboard, e.g. when using tmux or ssh. On the other hand, new users
enjoy having the mouse enabled by default, instead of having to figure
out how to make that work. Thus I didn't want to remove setting 'mouse'
by default.

The new value for 'mouse' is a compromise: The mouse works in Normal,
Visual and Insert mode, where it's most useful. In command-line mode
the mouse is not used by Vim, which means you can use the system
copy/paste mechanism. That way you can also copy/paste text in Vim
itself, instead of using the modeless selection. The only thing that no
longer works is moving the cursor in the command line with the mouse.
Which is a small price to pay.

I had been using ":sh" for this, but if I forget to type "exit" than I
have a Vim running in the background. Now it's just typing ":",
selecting and copying the text, then press Esc.

I hope this works best for most people. Can't please everyone though.

--
It doesn't really matter what you are able to do if you don't do it.
(Bram Moolenaar)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tony Mechelynck

unread,
Oct 27, 2019, 3:14:08 PM10/27/19
to vim_dev, Bram Moolenaar
Haven't compiled this yet. Can you still copy stuff from the
command-line by using Ctrl-Y in a modeless selection?


Best regards,
Tony.

Bram Moolenaar

unread,
Oct 27, 2019, 3:57:55 PM10/27/19
to vim...@googlegroups.com, Tony Mechelynck
With 'mouse' set to "nvi" you use the system copy/paste. E.g. when
using a Mac that is Command-C and Command-V.

I think that's fine for most people, CTRL-Y is probably much less known
than the system copy-paste keys. And if you have your own .vimrc you
won't get this change (unless you intentionally source defaults.vim).

--
Normal people believe that if it ain't broke, don't fix it. Engineers believe
that if it ain't broke, it doesn't have enough features yet.
(Scott Adams - The Dilbert principle)

Tony Mechelynck

unread,
Oct 27, 2019, 4:46:16 PM10/27/19
to Bram Moolenaar, vim_dev
And in GTK2 gvim?
>
> I think that's fine for most people, CTRL-Y is probably much less known
> than the system copy-paste keys. And if you have your own .vimrc you
> won't get this change (unless you intentionally source defaults.vim).

I intentionally source vimrc_example.vim after unletting
skip_defaults_vim if it exists.

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages