Question

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

Was it helpful?

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

OTHER TIPS

It looks like vim doesn't recognize the sql filetype from the extension. Try putting this into your .vimrc:

augroup filetypedetect
  au! BufRead,Bufnewfile *.sql setfiletype sql
augroup END

Uggggh, I'm an idiot!

I decided to remove all plugins except snipMate, and then I slowly added my plugins back in. I didn't realize it when I was hooking up snipMate, but I had already added a plugin previously for doing code completion called code complete. Apparently this nerd and snipMate were at war, so once I removed code complete snipMate miraculously began to work!

Hopefully this might help someone in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top