2

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.

Amaron
  • 163
  • 1
  • 7

1 Answers1

2

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

See

:help autocmd-nested
garyjohn
  • 34,610
  • 8
  • 97
  • 89
  • 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