1
1
I'm trying to reduce the number of things I need to do when I open VIM. I have the three following scenarios that I'd like to account for:
1. Open vim with a directory specified
vim .
For this case, I would like to open NERDTree, with this in my ~/.vimrc
:
autocmd vimenter * NERDTree
2. Open vim with a directory specified, on a large monitor
vim . --large
Here I'd like to open NERDTree as well as do some screen splits:
autocmd vimenter * NERDTree
autocmd vimenter * wincmd w
autocmd vimenter * wincmd v
autocmd vimenter * wincmd v
3. Open vim with a specific filename
vim ~/vimrc
For this case, I would like to not run any of the autocmd
s that I mentioned above.
Edit - Final implementation
Thanks to FDinoff's answer.
if argc() == 1 && arv(0) == '.' " `vim .` called
autocmd vimenter * NERDTree " Start up NERDTree
autocmd vimenter * wincmd w " Jump to split that file is open in
if !empty($L)
autocmd vimenter * wincmd v
autocmd vimenter * wincmd v
endif
endif
and run it with L=t vim .
, vim .
, or vim specific_file
Thanks! I'm updating the question with my final implementation. – RyanB – 2013-06-16T21:51:25.800
@RyanB You can also just define
L
in your bashrc so you don't have to type it every time. – FDinoff – 2013-06-16T22:00:06.450