18
9

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.

VimでNERDTreeもまとめて閉じる

Posted at

NERDTree以外に1つしかウィンドウを開いていないときにvimを終了したい ⇒ 2回終了コマンドを叩かないといけない。
これはめんどくさい!!

ということで一気にNERDTreeもまとめて閉じてくれるようにした。
ついでに$ vim(引数なし)で起動したときに自動で起動するようにした。

.vimrc

"引数なしでvimを開いたらNERDTreeを起動、
"引数ありならNERDTreeは起動せず、引数で渡されたファイルを開く。
autocmd vimenter * if !argc() | NERDTree | endif

"他のバッファをすべて閉じた時にNERDTreeが開いていたらNERDTreeも一緒に閉じる。
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

うん。地味だけど便利。

18
9
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?