5

When using the vim installed by default in macOS 10.12.5, I can copy text from the terminal by using cmd-C and pasting it into another applications. But when I use the latest version of vim (8.0.0771_1) installed by homebrew, it's impossible to copy any text from the terminal.

Why? and how to change this behavior?

vim installed by default:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  4 2017 18:14:54)
Included patches: 1-898, 8056
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_netterm   +syntax
-arabic          +file_in_path    -mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           -mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
+builtin_terms   -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    -keymap          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      -sniff           -xsmp
+eval            -mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv 

vim installed by homebrew:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jul 25 2017 12:36:48)
MacOS X (unix) version
Included patches: 1-771
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminal
++builtin_terms  +fork()          +multi_lang      +terminfo
+byte_offset     -gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
-clientserver    +insert_expand   +packages        +title
+clipboard       +job             +path_extra      -toolbar
+cmdline_compl   +jumplist        +perl            +user_commands
+cmdline_hist    +keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      +startuptime     -xpm
+eval            +mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
+farsi           +mouse_netterm   +tag_binary
   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_UNIX  -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        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.0/lib/perl5/5.26.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.1 -lobjc

2 Answers 2

8

There are few thing you can do to solve this. Homebrew compiled Huge version, while default Vim is in Normal version. Huge adds for example clipboard and more mouse/terminal support. This makes selecting with mouse actually select in Vim (so changes to Visual mode) instead of doing selection on terminal layer. Having that said, you can:

  • press "+y or "*y in Homebrew version after doing the selection,
  • ask Homebrew to compile Normal version or without mouse_* features (but I don't know the details of how to do that),
  • select holding Shift and then do the copy stuff as usual (holding Shift should make terminal selection and not passing this to the app running in that terminal)
  • set mouse= in your .vimrc to disable interaction with a mouse, but this will disable mouse support for good, so no more selecting focused window, resizing windows, etc.
5
  • Thank you for the answer. Maybe there is something to add to ~/.vimrc that solves the problem? Commented Aug 2, 2017 at 11:38
  • 4
    Hmm... now that you asked, maybe this will help set mouse=
    – grodzik
    Commented Aug 2, 2017 at 11:45
  • 3
    set mouse= did the trick, thank you! Commented Nov 21, 2018 at 7:20
  • 1
    Thanks! Stumbled across this after the same behaviour on vim/raspbian with the OS-X Terminal program. I didn't necessarily want to have to specify which version of vim I wanted on all the different platforms I manage and I didn't want to have to do some special keystrokes just to copy some text so set mouse= went into ~/.exrc and everything's back to the way it should be. Commented Jul 15, 2019 at 15:11
  • My scenario was similar. MacOS Terminal -> ssh -> Linux box (Ubuntu) -> vi (vim) -> Command+C. I used set mouse= in my ~/.vimrc. Commented Mar 27, 2023 at 12:09
0

Maybe not as good an answer here, but you can also use vi instead of vim command: it gets text copy enabled by default.

2
  • Thanks for contributing an answer. Did you realize the question was asked 6 years ago and was about differences in Vim versions 7.4 and 8.0? The current version is 9.0. Are you sure your answer is for this question, specifically? It will be impossible (or at least impractical) for anyone to verify it.
    – Friedrich
    Commented Sep 15, 2023 at 12:02
  • No, I didn't realize many details in the question. But I got here from a Google search for a related problem, and my answer 13 hours ago works for the most recent MacOS. Thought someone else could find my answer useful in this page.
    – Andrw
    Commented Sep 15, 2023 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.