I'm trying to figure out how to copy-and-paste between a file edited with Vim and the macOS Clipboard. Most instructions say to start by installing Vim using Homebrew as it will be installed with the clipboard option enabled (vim --version will display "+clipboard"). However, when I installed Vim using brew, the clipboard option was still set to "-clipboard". Can I force brew to reinstall Vim and turn this option on in the process? I'm using Homebrew 1.1.2 which installed VIM 7.4.
问题:
回答1:
Because Homebrew no longer takes package specific options on the command line you need to edit the formula to add support for the clipboard back and then tell brew to install from source and not from a bottle.
brew uninstall vim
brew edit vim
# Add `"--enable-clipboard",` after the `./configure` in the list of other options.
brew install -s vim
Summarized from this solution: https://coderwall.com/p/avmotq/gain-clipboard-support-for-vim-on-os-x
回答2:
Expanding on Andy Ray's comment…
MacVim is a GUI program but it also comes with a TUI executable that can be run in a terminal emulator. Because that TUI executable has all the features of the GUI program, installing MacVim is by far the easiest and safest way to have a full-featured and well optimized Vim on Mac OS X:
- Download the latest release.
- Mount the disk image.
- Drag and drop MacVim.app to
/Applications/
or~/Applications
. - Put the
mvim
scriptsomewhere in your
$PATH`. - [OPTIONAL] Add
alias vim='mvim -v'
to your shell's init script.
From your shell, you can do:
$ mvim foo.txt
to edit foo.txt
in the MacVim GUI,
$ mvim -v bar.txt
to edit bar.txt
in the MacVim TUI. Or, if you added the alias:
$ vim bar.txt
Now, to address your comment…
If you connect to your Mac from your Linux box, iTerm.app doesn't come into play and you can use whatever TUI program is installed on the Mac, including the Macvim TUI.
If you connect to your Linux box from your Mac, whether it is via iTerm.app or Terminal.app, the vim
you are going to run will be the vim
on your Linux machine so… what programs you install on your Mac doesn't matter at all as you won't have access to them anyway.