LoginSignup
5
9

More than 5 years have passed since last update.

deinに乗り換えよう(第一段階)

Last updated at Posted at 2016-12-11

前提条件

  • MacOS ElCapitan 10.11.6(やんごとなき事情で再インストールした後、しばらくヤル気を失って放置w)
  • vim7.3→8.0
  • homebrew
  • 再インストール前はNeoBundle使ってましたが、NeoBundleはもう更新されないらしいので、初めてのdein

手順

vimのバージョンを上げる

デフォルトでvim7.3が入っているが、7.4以上でないとdein.vimが使えない
homebrewでvimをバージョンアップするといくつになるのか・・・?

$ brew info vim
vim: stable 8.0.0022 (bottled), HEAD
・・・以下略

というわけで8.0になるらしいです。

$  brew install vim --with-lua
・・・略
/usr/local/Cellar/vim/8.0.0130: 1,713 files, 23.3M, built in 57 seconds

で、一旦ターミナルを抜けてから

$ vim -h
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 11 2016 18:01:49)

というわけで、無事アップデート

deinのインストール

Shougoさんのgithubだと

$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
$ sh ./installer.sh {specify the installation directory}

と書かれているので、ディレクトリが指定できるらしい。
今回は再インストール直後のmacなので、ディレクトリも作ります
.vim/deinを作ってインストール

$ mkdir .vim
$ mkdir .vim/dein
$ cd .vim/dein/
$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2234  100  2234    0     0   1357      0  0:00:01  0:00:01 --:--:--  1358


$ sh installer.sh ~/.vim/dein
Install to "/Users/MineDir/.vim/dein/repos/github.com/Shougo/dein.vim"...

インストールの最後に

"dein Scripts-----------------------------

if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/Users/MineDir/.vim/dein/repos/github.com/Shougo/dein.vim

" Required:
call dein#begin('/Users/MineDir/.vim/dein')

" Let dein manage dein
" Required:
call dein#add('Shougo/dein.vim')

" Add or remove your plugins here:
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')

" You can specify revision/branch/tag.
call dein#add('Shougo/vimshell', { 'rev': '3787e5' })

" Required:
call dein#end()

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
"if dein#check_install()
"  call dein#install()
"endif

"End dein Scripts-------------------------

.vimrcに追加してねスクリプトが書かれているので、コピペ。
今回は再インストール直後で.vimrcがない。
というわけで作成。
・・・が、ここで問題発生。

$ cd
$ vi .vimrc
[dein] Does not work in the Vim (703).
[dein] Invalid begin/end block usage.
Press ENTER or type command to continue

え?さっき8.0入れましたけど・・・?
あ・・・

$ vim -h
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 11 2016 18:01:49)
$ vi -h
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 14 2016 16:06:49)

ついクセでviって打ったけど、Macの場合

$ which vim
/usr/local/bin/vim
$ which vi
/usr/bin/vi
$ ls -al /usr/bin/
・・・略
lrwxr-xr-x     1 root   wheel         3 10 10 14:14 vi -> vim
lrwxr-xr-x     1 root   wheel         3 10 10 14:14 view -> vim
-rwxr-xr-x     1 root   wheel   1530064  7  9 12:03 vim
lrwxr-xr-x     1 root   wheel         3 10 10 14:14 vimdiff -> vim
・・・略

さっき入れ直したのはvim
viはvimにシンボリックリンクが張られているけど、/usr/bin/vimを参照してる・・・というわけでした。
じゃ、シンボリックリンク張り直せばいーんじゃね?
と安直に思ったわけです・・・

$ sudo ln -nfs /usr/local/bin/vim /usr/bin/vi
ln: /usr/bin/vi: Operation not permitted

sudoつけたのに何でやねん・・・
と思ったら、ElCapitanの罠。SIP。
/usrとか/sbinとか、大事なファイルは上書きさせない・・・ということですか。そうですか。
切る方法が複数のサイトに載ってるんですが、リカバリモードで云々・・・
いや、これだけのために切るのも・・・。
次の策で。

$ vi .bash_profile

alias vi='vim'
alias view='vim'
alias vimdiff='vim -d'

$ source .bash_profile

これでviを参照してたものは新しいバージョンのvimを参照。
(2017/1/22 vimdiffの部分を修正しました。vimだけだとdiffモードにならなかったので・・・)

$ vi .vimrc

で最後のif文のコメントアウトを解除して、もう一度

$ vi .vimrc
[dein] Not installed plugins: ['vimshell', 'neosnippet.vim', 'neosnippet-snippets']
[dein] Update started: (2016/12/11 21:02:10)
[dein] (1/3) |vimshell            | git clone --recursive https://github.com/Shougo/vimshell.git "/Users/MineDir/.vim/dein/repos/github.com/Shougo/vimshell"
[dein] (1/3) [======              ] vimshell
[dein] (2/3) |neosnippet.vim      | git clone --recursive https://github.com/Shougo/neosnippet.vim.git "/Users/MineDir/.vim/dein/repos/github.com/Shougo/neosnippet.vim"
[dein] (2/3) [=============       ] neosnippet.vim
[dein] (3/3) |neosnippet-snippets | git clone --recursive https://github.com/Shougo/neosnippet-snippets.git "/Users/MineDir/.vim/dein/repos/github.com/Shougo/neosnippet-snippets"
[dein] (3/3) [====================] neosnippet-snippets
[dein] (1/3) |vimshell            | Locked
[dein] (1/3) |vimshell            | Updated
[dein] (1/3)  -> 3787e52766812d8b99a93ccdda57517bc2a0bab6
[dein] (2/3) |neosnippet.vim      | Updated
[dein] (2/3)  -> 3929abc3538db6e1b5958acc5f07cdad4345f86d
[dein] (3/3) |neosnippet-snippets | Updated
[dein] (3/3)  -> 4431bf176650696d5a8dd93814812afd0d06212c
[dein] Updated plugins:
[dein]   vimshell(1 change)
[dein]   neosnippet.vim(1 change)
[dein]   neosnippet-snippets(1 change)
[dein] Done: (2016/12/11 21:02:20)
Press ENTER or type command to continue

はい。これでデフォルトの設定でdein.vimが入りました。
次は、使いやすい環境にすべくプラグインを追加予定。

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