title: Automatic syntax highlighting will not work in gVim
body: <p>I think I've tried every intuitive combination of these four commands, with and without colons, in my _vimrc:</p>
  
  <pre><code>syntax enable
  syntax on
  set filetype=r
  set syntax=r
  </code></pre>
  
  <p>But when I open a script in gVim, it's all one solid color. Within a session, both ':set syntax=r' and ':set filetype=r' work fine, while the other two do nothing.</p>
  
  <p>My full _vimrc is below:</p>
  
  <pre><code>set nocompatible
  source $VIMRUNTIME/vimrc_example.vim
  source $VIMRUNTIME/mswin.vim
  behave mswin
  set keymodel-=stopsel
  
  set diffexpr=MyDiff()
  function MyDiff()
    let opt = '-a --binary '
    if &amp;diffopt =~ 'icase' | let opt = opt . '-i ' | endif
    if &amp;diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
    let arg1 = v:fname_in
    if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
    let arg2 = v:fname_new
    if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
    let arg3 = v:fname_out
    if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
    let eq = ''
    if $VIMRUNTIME =~ ' '
      if &amp;sh =~ '\&lt;cmd'
        let cmd = '""' . $VIMRUNTIME . '\diff"'
        let eq = '"'
      else
        let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
      endif
    else
      let cmd = $VIMRUNTIME . '\diff'
    endif
    silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' &gt; ' . arg3 . eq
  endfunction
  
  filetype plugin indent on
  " show existing tab with 4 spaces width
  set tabstop=4
  " when indenting with '&gt;', use 4 spaces width
  set shiftwidth=4
  " On pressing tab, insert 4 spaces
  set expandtab
  
  "show line numbers
  set number
  
  "syntax highlighting for R
  "syntax enable
  syntax on
  set filetype=r
  "set syntax=r
  colorscheme elflord
  
  "see commands as they're being typed
  set showcmd
  
  "change the key combo for normal mode to 'jk'
  inoremap jk &lt;ESC&gt;
  
  "add line below cursor in insert mode
  :autocmd InsertEnter * set cul
  :autocmd InsertLeave * set nocul
  </code></pre>