2

I use NERDTree and have it set to automatically open when I open vim, but that causes the NERDTree window to be the one selected, which isn't what I want. I want to be able to go right into editing the file I opened, but autocmd vimenter * <c-w><c-p> just gives me an error on startup. Is there any way to do what I'm wanting to do, or is it impossible?

I'm not completely familiar with Vim and its configuration files, so excuse me if this is a simple question, but I haven't been able to find it anywhere.

Ashen
  • 23
  • 4

1 Answers1

5

:autocmd's execute ex-commands not normal mode commands. This means you can use :normal! or use :wincmd (method I prefer).

Your new command:

autocmd VimEnter * wincmd p

Note: wincmd p is the same as <c-w>p or <c-w><c-p> in normal mode.

For more help see:

:h :wincmd
:h :normal
:h :au
JeroenHoek
  • 1,448
  • 15
  • 24
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
  • It seems like you meant `wincmd` rather than `windcmd`, but thanks. It worked once I figured that bit out. I'll mark this as the correct answer if that bit's edited. – Ashen Jan 15 '15 at 00:28