LoginSignup
10
10

More than 5 years have passed since last update.

コンソールVimのヤンクでMacのクリップボードにコピー

Posted at

やってみよ。

参考にさせていただいたサイト

【Vim】【Mac】Vimのヤンクでクリップボードにコピーする

基本の流れ

基本は.vimrcに以下を書けばOKらしいです。

set clipboard=unnamed,autoselect

ところが、vimのビルドによってはできないということで、チェック。

vim --version | grep clipboard
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
 -xterm_clipboard -xterm_save 

-clipboardってことで、クリップボード共有はできないビルドみたい。

MacPortを使ってvimをインストール

それなら+clipboadなvimを入れてしまいましょう、ということでチャレンジ。

$ port variants vim
vim has the variants:
   athena: Build GUI version using Athena widgets
     * conflicts with gtk1 gtk2 motif
     * requires x11
   big: Build big feature set
     * conflicts with small tiny
   cscope: Enable source code browsing with cscope
   gtk1: Build GUI version using GTK 1.x widgets
     * conflicts with athena gtk2 motif
     * requires x11
   gtk2: Build GUI version using GTK 2.x widgets
     * conflicts with athena gtk1 motif
     * requires x11
[+]huge: Build huge feature set
     * conflicts with big small tiny
   motif: Build GUI version with Motif widgets
     * conflicts with athena gtk1 gtk2
     * requires x11
   perl: Enable Perl scripting
   python: Compatibility variant, requires +python25
     * requires python25
   python25: Enable Python scripting
     * conflicts with python26 python27
   python26: Enable Python scripting
     * conflicts with python25 python27
   python27: Enable Python scripting
     * conflicts with python25 python26
   python31: Enable Python scripting
     * conflicts with python32 python33
   python32: Enable Python scripting
     * conflicts with python31 python33
   python33: Enable Python scripting
     * conflicts with python31 python32
   ruby: Compatibility variant, requires +ruby18
     * requires ruby18
   ruby18: Enable Ruby scripting
     * conflicts with ruby19
   ruby19: Enable Ruby scripting
     * conflicts with ruby
   small: Build small feature set
     * conflicts with tiny
   tcl: Enable Tcl scripting
   tiny: Build tiny feature set
   universal: Build for multiple architectures
   x11: Build CLI version with X support
   xim: Build with support for X Input Method

うーんどれでクリップボード有効になるのか分かりませんが、上記参考サイトによりますと、+rubyしちゃえばできるようになるみたいです。ちょうどいいや、やってみよ。

sudo port install vim +ruby

それなりにお時間がかかります。
完了後、~/.bash_profileにviとvimのエイリアスを指定します。

alias vim='env LANG=ja_JP.UTF-8 /opt/local/bin/vim'
alias vi='env LANG=ja_JP.UTF-8 /opt/local/bin/vim'

確認してみましょう。

$ source ~/.bash_profile
$ vi --version | grep clipboard
+clipboard       +iconv           +path_extra      -toolbar
+eval            +mouse_dec       +startuptime     -xterm_clipboard
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10