[vim/vim] reg * System clipboard not working - MacOSX (#2528)

85 views
Skip to first unread message

Lyle Cheatham

unread,
Jan 4, 2018, 6:30:40 PM1/4/18
to vim/vim, Subscribed

Hey All,

I'm clean out of ideas right now and I can't get the system clipboard to work in vim. I had it working, then at some point this week it stopped working.

Essentially I am just trying to use "*y and "*p to copy and paste from my system clipboard, but it seems that reg "* is just it's own register, with no relation to my system clipboard.

I'm running Mac OS 10.12.6

vim version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan  4 2018 17:51:10)
macOS version
Included patches: 1-1400
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    -gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python            +vreplace
+conceal           +linebreak         -python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               +ruby              +X11
+dialog_con        +menu              +scrollbind        +xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       +xsmp_interact
-ebcdic            -mouseshape        +statusline        +xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim    -lXt -lX11 -lSM -lICE  -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.5.0 -lobjc

If you don't feel like scanning that, yes it has +clipboard and +xterm_clipboard

  • I'm not running it in tmux (I was, but I removed it from the equation)
  • I am running without a .vimrc so it shouldn't be that
  • I have tested in both iTerm and Terminal
  • I am running vim with vim -N -u NONE as recommended

A more in depth example step by step behavior below:

  1. in browser, copy piece of text A with cmd + c
  2. in vim: shift + v to select piece of text B, then "*y to put it in reg *
  3. :reg * to confirm that text B is in the register
  4. go to browser, try to paste with cmd + v, get piece of text A
  5. go to vim, use "*p to paste and get piece of text B
  6. in vim, in insert mode, use cmd + v and get piece of text A

The register seems to be totally unattached from the system clipboard


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Tony Mechelynck

unread,
Jan 4, 2018, 7:27:46 PM1/4/18
to vim_dev, reply+00b1d1983173a6707edc2077a12fcb786b9ae5f...@reply.github.com, vim/vim, Subscribed
On Fri, Jan 5, 2018 at 12:30 AM, Lyle Cheatham
<vim-dev...@256bit.org> wrote:
> Hey All,
>
> I'm clean out of ideas right now and I can't get the system clipboard to
> work in vim. I had it working, then at some point this week it stopped
> working.
>
> Essentially I am just trying to use "*y and "*p to copy and paste from my
> system clipboard, but it seems that reg "* is just it's own register, with
> no relation to my system clipboard.
>
> I'm running Mac OS 10.12.6
>
> vim version:

Huge version without GUI, but compiled with +X11. Have you tried to
run it in an xterm within X11, rather than in the native Cocoa GUI?

Best regards,
Tony.

vim-dev ML

unread,
Jan 4, 2018, 7:28:01 PM1/4/18
to vim/vim, vim-dev ML, Your activity
On Fri, Jan 5, 2018 at 12:30 AM, Lyle Cheatham
<vim-dev...@256bit.org> wrote:
> Hey All,
>
> I'm clean out of ideas right now and I can't get the system clipboard to
> work in vim. I had it working, then at some point this week it stopped
> working.
>
> Essentially I am just trying to use "*y and "*p to copy and paste from my
> system clipboard, but it seems that reg "* is just it's own register, with
> no relation to my system clipboard.
>
> I'm running Mac OS 10.12.6
>
> vim version:

Huge version without GUI, but compiled with +X11. Have you tried to
run it in an xterm within X11, rather than in the native Cocoa GUI?

Best regards,
Tony.

Lyle Cheatham

unread,
Jan 4, 2018, 7:43:24 PM1/4/18
to vim/vim, vim-dev ML, Comment

Wow! So mac doesn't really have X11 but it does have XQuartz (correct me if I'm wrong, I just spent a grand total of 2 minutes reading on it), but I ran Terminal in XQuartz and it worked!

More interesting though, is outside of XQuartz, I got vim to work by using the + register instead of the * register, i.e. "+y. I have no idea why this works now instead of the * register, I definitely remember it being the other way around. If you have any suggestions on how to remap registers I'm all ears now :P

-Lyle


You are receiving this because you commented.

Tony Mechelynck

unread,
Jan 4, 2018, 8:16:41 PM1/4/18
to vim/vim, vim-dev ML, Comment

I suppose that XQuartz on Mac OS X, like X.Org on the brand of Linux I'm using, are names for specific implementations of what is collectively described (generically, and maybe a little abusively) as X11.

On systems where X11 (or one of its avatars) is present, the + register is used for Edit→Cut, Edit→Copy and Edit→Paste while the * register is used by highlighting (the latest highlight by mouse-drag, shift-arrow, etc.) for copying and by MiddleMouse for pasting. On other systems such as Windows, + and * registers are synonymous — two names for one register.

On my system, it is possible to log in to a text-only terminal (by hitting anything from Ctrl-Alt-F1 to Ctrl-Alt-F6) but those "text only" consoles have no connection to X11 (or to XOrg) and no clipboard. When I was on Windows, the "dos box" ran within Windows like xterm et al. run within X11 and it had access to the clipboard.

I've spent less than a day on a Mac and that was a long, long, long time ago so I really don't know what makes it tick. Each of Vim's 45 or so registers has its own individuality; you can copy stuff from one to the other (and even use most of them as variables e.g. :let @A = @b . @c but AFAIK you cannot "remap" them to give them different names than the compiled-in ones. For more info, a good place to start is at ":help copy-move" (of course without the quotes, but with the colon, and followed by hitting Enter) in a running Vim.

Best regards,
Tony.


You are receiving this because you commented.

Christian Brabandt

unread,
Jan 5, 2018, 3:16:06 AM1/5/18
to vim/vim, vim-dev ML, Comment

I know on Windows register + and register * are the same. On Unix they are differently used for the Clipboard and primary selection (when an X server is present). Don't know nothing about Mac


You are receiving this because you commented.

Christian Brabandt

unread,
Jan 6, 2018, 8:44:54 AM1/6/18
to vim/vim, vim-dev ML, Comment

can this be closed?


You are receiving this because you commented.

Kazunobu Kuriyama

unread,
Jan 6, 2018, 1:28:59 PM1/6/18
to vim/vim, vim-dev ML, Comment

@lylecheatham

Your description of the issue looks very conflicting to me. Can you clarify the following points?:

  1. After all, which clipboard do you want to use, macOS's native one or the one provided through the X11 selection mechanism? Obviously your Vim is now using the latter, and that thing cannot happen unless you install XQuartz for yourself (macOS has discontinued installing X11 by default since Mountain Lion, or 10.8) and specify by yourself some configure options for Vim to enable it. So, while it appears that you want to use the latter, the issue description itself sounds like discontent at the consequence of what you must have done for your Mac and Vim this week. Since your intention is unclear to me, I haven't been able to give a comment on the issue.

  2. The configure options you used to build the Vim the * register of which stopped working with the system clipboard. Probably, that's the core of the issue.


You are receiving this because you commented.

Lyle Cheatham

unread,
Jan 16, 2018, 3:01:40 PM1/16/18
to vim/vim, vim-dev ML, Comment

Okay, sorry for being a bad issue reporter here.

So timeline of events is that it used to map my system clipboard (I believe it's the native one because it works natively in any other app as just cmd+v and cmd+c) on the * register, then it changed to the + register, and then now it has stopped working on either register.

I can still use pbcopy and pbpaste in my shell to access the system clipboard, but vim doesn't seem to have any access to it, and it has the same behavior where the * and + register seem to be just their own registers, disconnected from anything my system clipboard is doing.


You are receiving this because you commented.

Ruben Di Battista

unread,
Jan 23, 2018, 11:41:45 AM1/23/18
to vim/vim, vim-dev ML, Comment

I have the feeling that you installed vim using Macports with the +x11 variant. Is this the case? Well did you try just to Command+V to paste stuff? It should work natively. (Still did not understand how to copy, tought...)


You are receiving this because you commented.

Alan Berezin

unread,
Feb 14, 2018, 7:18:58 PM2/14/18
to vim/vim, vim-dev ML, Comment

FWIW, Here is what I see on MacOS 10.12.6 with vim @8.0.1420_0+gtk2+huge+x11 (active)

XQuartz terminal, copy to "+ is viewable on osx system clipboard
XQuartz terminal, copy to "* Not viewable on osx system clipboard
iTerm3, copy to "+ is viewable on osx system clipboard
iTerm3, copy to "* Not viewable on osx system clipboard
OS X terminal same as XQuartz and iTerm3 behavior

So I think it behaves as expected.

I used this to map unnamed to the system clipboard
"http://www.markcampbell.me/2016/04/12/setting-up-yank-to-clipboard-on-a-mac-with-vim.html


You are receiving this because you commented.

Alfredo Deza

unread,
Apr 10, 2018, 2:06:22 PM4/10/18
to vim/vim, vim-dev ML, Comment

I am experiencing the same issue, which was not happening with the 7.x series on OSX.

vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr  9 2018 19:55:20)
macOS version
Included patches: 1-1650
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    -gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua               +ruby              +X11
+dialog_con        +menu              +scrollbind        +xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       +xsmp_interact
-ebcdic            -mouseshape        +statusline        +xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim    -lXt -lX11 -lSM -lICE  -lncurses -liconv -framework AppKit  -L/usr/local/lib -llua -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -lruby.2.5.1 -lobjc

It has both +clipboard and +xterm_clipboard

I am able to replicate exactly as the subject on this issue:

  1. set clipboard=unnamed
  2. yank a line in vim, confirm it shows in :reg *
  3. Use system clipboard to paste outside of Vim (e.g. in a browser) and contents from reg * are not there

The same behavior happens vice versa: copying something outside of Vim and it will not show up in reg * and it will not appear when putting.

However! It does work fine with MacVim. This is only a behavior on terminal Vim (both iTerm and terminal applications)

I am happy to provide any other information to get a fix for this issue.


You are receiving this because you commented.

Evans Hauser

unread,
Apr 20, 2018, 4:41:33 PM4/20/18
to vim/vim, vim-dev ML, Comment

@alfredodeza I was running into the same issue as you. I followed the XQuartz instructions found (here)[http://www.markcampbell.me/2016/04/12/setting-up-yank-to-clipboard-on-a-mac-with-vim.html] and that seems to have resolved the part of the issue I was having with 8.x. I'm now able to yank from vim into the system clipboard, but when I copy, outside of vim, "* and "+ are not updated. My setup is iterm2, vim 8.0.1700 and apparently an XQuartz server. Hopefully this helps.

xquartz_preferences


You are receiving this because you commented.

Kazunobu Kuriyama

unread,
Apr 21, 2018, 3:58:50 AM4/21/18
to vim/vim, vim-dev ML, Comment

It has both +clipboard and +xterm_clipboard

Why do you need +xterm_clipboard? As far as copy and paste via *-register is concerned, you don't need XQuartz at all.

I am able to replicate exactly as the subject on this issue:

set clipboard=unnamed
yank a line in vim, confirm it shows in :reg *
Use system clipboard to paste outside of Vim (e.g. in a browser) and contents from reg * are not there
The same behavior happens vice versa: copying something outside of Vim and it will not show up in reg * and it will not appear when putting.

Actually, that's no surprise to me. The output of :version tells us that you configured and built Vim, intentionally or inadvertently, so that it would use X11 selection mechanism for copy and paste instead of macOS' system clipboard. No one expects that such a Vim is able to interoperate via *-register with other native macOS applications which inherently don't know anything about that X11 mechanism.

Moreover, the Vim was built with the darwin feature as well, which means that the system clipboard integration is also compiled in the executable in addition to the X11 mechanism, although the former remains inactive somehow. How could that be possible with the configure script? I asked the OP about that but he never replied to me about that. That's why I didn't know what to do further on this issue.

Anyway, you shouldn't/cannot enable both X11 selection mechanism and the system clipboard integration simultaneously; in other words, you have to choose either --enable-darwin (default) or --disable-darwin --with-x --without-gui.

However! It does work fine with MacVim. This is only a behavior on terminal Vim (both iTerm and terminal applications)

That's because MacVim is built with --enable-darwin (default) and doesn't rely on any bit of XQuartz.


You are receiving this because you commented.

Alfredo Deza

unread,
Apr 21, 2018, 8:25:13 AM4/21/18
to vim/vim, vim-dev ML, Comment

@nuko8 I can confirm that MacVim is built like: -xterm_clipboard and +clipboard

I don't need +xterm_clipboard, that was set/default with the homebrew version that built Vim for me.

I'll try to re-compile using -xterm_clipboard and report back. Thank you so much for going through this issue and taking the time to explain it better.


You are receiving this because you commented.

Kazunobu Kuriyama

unread,
Apr 21, 2018, 8:29:58 AM4/21/18
to vim/vim, vim-dev ML, Comment

In case you find the resulting Vim still linking against X11 dylibs, try adding --without-x to your configure options. Good luck!


You are receiving this because you commented.

Alfredo Deza

unread,
Apr 21, 2018, 8:38:20 AM4/21/18
to vim/vim, vim-dev ML, Comment

I can confirm the behavior is exactly as what @nuko8 has described on OSX using Homebrew: ensuring that -xterm_clipboard is set will make the clipboard support work as expected.

It is possible that this was pre-built as a "bottle" with the wrong flags, so Homebrew users would need to rebuild from source (brew install -s vim) or ensure that their cached vim bottle is gone.

The following version of homebrew worked for me:

brew --version
Homebrew 1.6.1-28-g1d9746d
Homebrew/homebrew-core (git revision 53a2a; last commit 2018-04-21)

Other users will just need to ensure that vim is built using -xterm_clipboard

I believe this should close this issue as it is not a problem with Vim. Thanks again again @nuko8 !


You are receiving this because you commented.

Christian Brabandt

unread,
Apr 22, 2018, 3:18:55 AM4/22/18
to vim/vim, vim-dev ML, Comment

closing then


You are receiving this because you commented.

Christian Brabandt

unread,
Apr 22, 2018, 3:18:56 AM4/22/18
to vim/vim, vim-dev ML, Comment

Closed #2528.


You are receiving this because you commented.

Narek Asadorian

unread,
May 27, 2019, 12:15:31 AM5/27/19
to vim/vim, vim-dev ML, Comment

@alfredodeza @nuko8 Would you mind sharing the code you used to compile Vim with this flag +clipboard and -xterm_clipboard?

Running into a similar issue compiling Vim on macOS (using Nix package manager). Installation shows both +clipboard and +xterm_clipboard. This causes an error when set clipboard=unnamed, and when set clipboard=autoselect, Vim is not copying to system clipboard.

My current configure flags are --enable-darwin --without-x --without-gui.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages