0
0

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.

ホームディレクトリ以外の.vimrcを使う

Posted at

諸事情で一時期共有ユーザーアカウントを使う羽目になり、
自分の.vimrcを使えなくて大変困ったので、
将来の自分へ宛ててメモ

常識的に考えてユーザーアカウントは分けたほうがいいよ絶対。

よく言われる手順

ネットを調べると単に-uで.vimrcを読みこませる手順が多いが、
筆者の場合、~/.vim/フォルダもホームディレクトリ以外に置きたいので、これだと困る。

$ vim -u /filepath/dotfiles/.vimrc

なお、この記事では設定ファイルは/filepath/dotfiles/に入っている前提とする。
以下のような感じ。

  • /filepath/dotfiles/.vimrc
  • /filepath/dotfiles/.vim/

~/.vim/フォルダも別のパスに移す手順

  1. まず、.vimrc, .vim/を以下の通りにリネームする。
    • .vimrc -> vimrc
    • .vim/ -> vimfiles
  2. 以下のコマンドでvimを起動すると/filepath/dotfiles/.vim/以下もきちんと読み込んでくれる。
$ VIM=/filepath/dotfiles/ VIMRUNTIME=/usr/local/share/vim/vim81 vim

VIMRUNTIMEのところは環境に合わせて適宜変えてあげる必要がある。
筆者の場合、自分でビルドしたvimを使っているのでこのパスだけど、
ubuntuなら普通は/usr/share/vim/vimXXとかになると思う。
MAC, Windowsはわからない。

aliasを設定する

毎回打つのはだるいのでaliasを設定する。
~/.bashrcとかに書きたくなるけれど、ホームディレクトリのファイルを弄りたくないので、
これは端末開くたびに打つしか無いか。。。

$ alias myvim="VIM=/filepath/dotfiles/ VIMRUNTIME=/usr/local/share/vim/vim81 vim"
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?