Reputation: 706
my question is similar to this one https://superuser.com/questions/277051/how-can-i-emulate-key-presses-on-vim-startup
I'm using the plugin netrw in my vim instead of nerdtree in that question. I add the following line to enable netrw automatically.
autocmd BufWinEnter * :Ve
While open vim, I need to press ^W^W each time because the active buffer is the left one, where the netrw is located.
How can I make vim emulate these key presses on startup? In fact, I've got it works before, but I didn't save my .vimrc in a recently re-installation of OS.
The answer of that question doesn't work for me.
My environment: Mac OS X 10.9.5 MacVim Snapshot 73
Any answers appreciated, thanks a lot :)
Upvotes: 3
Views: 1732
Reputation: 172560
Best way is by just appending the command to the existing :autocmd
(separated by |
):
autocmd BufWinEnter * Vexplore | wincmd w
BufWinEnter
, this will open a netrw split on each displaying of a buffer. If you just want to trigger this once at Vim startup, VimEnter
is the right event to use.:VerticalSplit
). Also, you don't need the :
in autocmds.<C-W>
window commands, there's the special :wincmd
Ex command to trigger those. For all else, you would use :execute 'normal! \<C-w>\<C-w>'
.Upvotes: 1