Search code examples
vimsnipmate

snipMate only working on empty buffer?


I'm attempting to use snipMate with sql files, however it doesn't seem to work when editing an existing file.

If I create a new empty buffer (no file; e.g. launch gvim from the start menu), and set the filetype to sql (:set ft=sql), it works. However, if I then try to open a sql file (e.g. :e c:\blah.sql) and edit it, snipMate no longer works. What gives!?

Setup:

  • gvim
  • vim 7.3
  • Windows 7
  • snipMate 0.84
  • Also, I do in fact have filetype plugin on in my .vimrc file.

edit

Apparently if I open an empty buffer, set the filetype to sql, then save to file using w c:\blah.sql, I now have a sql file open AND snipMate continues to work.

edit

Here's a gist of my current .vimrc in case it helps: https://gist.github.com/3946877


Solution

  • I have tried your .vimrc on my computer and it works fine. There's a filetype.vim file in $VIMRUNTIME which detects filetypes on startup and most likely you have some problem within that file. These are the relevant lines from mine:

    " SQL
    au BufNewFile,BufRead *.sql         call s:SQL()
    
    func! s:SQL()
      if exists("g:filetype_sql")
        exe "setf " . g:filetype_sql
      else
        setf sql
      endif
    endfunc
    

    You can copy these to $VIMRUNTIME/filetype.vim or just to your .vimrc and that should solve the problem but then again you shouldn't have this problem in the first place.

    Let me know how you progress..

    NOTE $VIMRUNTIME is /usr/share/vim/vim73 in my machine, you can find yours by running :echo $VIMRUNTIME in a vim session