I have an issue with using GVim on Windows. I have set up the following in my .vimrc:
autocmd VIMEnter * :source C:/session.vim
Unfortunately this creates a problem. If I'm a the top of the file and try to move up a line (k), the screen flashes. If I hold the key for just a second it will flash a few dozen times, it is really nasty too look at.
I've tried using GUIEnter instead but I got the same results. The docs mention that I can fire an autocommand only once, but I couldn't figure out the exact syntax. Care to help?
I assume you can get an autocommand to fire only once if you clear it in whatever command is called in the autocommand. For example, in the example code you give it would fire only once if c:/session.vim contained this command:
autocmd! VimEnter *
Like frabjous says in his comment, though, it sounds like your problem is one with the visual bell, see
I have a function dedicated to this: lh#event#register_for_one_execution_at(). The idea is indeed to clear the event once executed.
But I also suspect another issue. Vimenter is not the kind of event that is fired several times anyway.
As frabjous mentioned, I had to turn off the visualbell. However, the documentation mentions that the visualbell is reset to its default when the GUI starts. Putting "set vb t_vb=" on the top of a .vimrc to disable the visualbell wouldn't work, because it is reset on entry to the GUI. Instead, the trick is to disable the visualbell with an autcommand:
autocmd GUIEnter * :set vb t_vb=