9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacのVimでクリップボード連携を有効にする(El Capitan対応)

Posted at

問題点

  • Mac標準で利用できる/usr/bin/vim(vi実行時も、本コマンドが実行される)では、他アプリとクリップボードを連携できない
  • OS X 10.11 El Capitanから新しくセキュリティ機能が追加され、sudoをつけても/usr/bin配下の既存のvivimコマンドを上書きできない

対処手順

  1. 標準vimがクリップボード連携できないことを確認

    % /usr/bin/vim --version | grep clipboard
    -clipboard       +iconv           +path_extra      -toolbar
    +eval            -mouse_dec       +startuptime     -xterm_clipboard
    
  2. Homebrewを使ってVimを入れる

    brew update
    brew install vim
    
  3. インストールしたvimがクリップボード連携できるか確認する

    $ /usr/local/Cellar/vim/8.0.0134/bin/vim --version | grep clipboard
    +clipboard       +job             +path_extra      +user_commands
    +eval            +mouse_dec       +statusline      -xterm_clipboard
    
  4. 既存のvimを置き換えるための操作

    1. Macを再起動し、Command+Rを押してリカバリーモードで起動

    2. メニューからユーティリティ->ターミナルを選択し、ターミナルを起動

    3. 現在のSystem Integrity Protectionの状態を確認

      # csrutil status
      System Integrity Protection status: enabled.
      
    4. System Integrity Protectionを無効化

      # csrutil disable
      Successufully disabled System Integrity Protection. Please restart the machine for the changes to take effect.  
      # reboot
      
    5. System Integrity Protectionの状態を確認(reboot後)

      % csrutil status
      System Integrity Protection status: disabled.
      
  5. 既存のvimを置き換え

    sudo mv /usr/bin/vim /usr/bin/old_vim                                                                                                                                           
    sudo ln /usr/local/Cellar/vim/8.0.0134/bin/vim /usr/bin/
    
  6. ~/.vimrcに以下の設定を追加

    set clipboard+=unnamed
    
9
8
2

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
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?