Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently attempting to create a basic screen layout for gvim that shows up every time it opens. I'm also attempting to open buffers in a certain window. Because of the GUI init timing I'm forced to open the buffers with autocmd.

So my _gvimrc looks like this:

winpos 4 2
set co = 200
set lines = 50
autocmd GUIEnter * vsplit
autocmd GUIEnter * wincmd b
autocmd GUIEnter * split
autocmd GUIEnter * edit /users/user/_gvimrc

The problem is when I do this the gvimrc loses it's highlighting. So I tried VimEnter but that doesn't work either. Perhaps it's loading before the syntax files are sourced but I've no clue how to fix that.

share|improve this question
up vote 2 down vote accepted

The problem is that syntax highlighting is executed as an autocommand and autocommands do not nest by default. The solution is to change that last autocommand to

autocmd GUIEnter * nested edit /users/user/_gvimrc


:help autocmd-nested
share|improve this answer
Thanks I figured I was just missing something obvious! – Amaron Dec 29 '12 at 23:09
You're welcome. Maybe not so obvious, though. The reason I happened to know the answer was that I added a similar GUIEnter autocommand to my ~/.vimrc a few weeks ago and, like you, wondered for a while why my highlighting was messed up until I remembered the nested issue. – garyjohn Dec 29 '12 at 23:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.