Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

問題点

  • 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
    
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした