I'd like to open
CtrlP if I am opening a directory with vim, but not a file. I like to have it automatically open in I just open a directory for convenience. However, it is slightly inconvenient if I know exactly which file I want to open because of the added loading time.
Currently I just have this in my
autocmd vimenter * CtrlP
Thanks in advance for any responses!
You can write a function to test the args to see if a single directory was passed in and if it was, execute
CtrlP. Here is a very rudimentary solution:
function! MaybeCtrlP() if argc() == 1 && isdirectory(argv()) " Uncomment this to remove the Netrw buffer (optional) " execute "bdelete" execute "CtrlP" endif endfunction autocmd VimEnter * :call MaybeCtrlP()
.bash_profile, create an alias:
alias vimCtrlP="vim +CtrlP"
Then every time you need this, use
vimCtrlP as you would issue
vim in shell, followed by the directory.