1

I am using a plugin that redefine a filetype:

cat ~/.vim/bundle/kdb-vim/filetype.vim

if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufRead,BufNewFile *.k            setfiletype k
  au! BufRead,BufNewFile *.q            setfiletype q
  au! BufRead,BufNewFile *.s            setfiletype sql
augroup END

And in my vimrc:

set nocompatible
filetype off                                            
                                                                                                    
set rtp+=~/.vim/bundle/vundle                                                                       
set rtp+=~/.vim/bundle/Align                                                                        
set rtp+=~/.vim/bundle/Vim-R-plugin                                                                 
set rtp+=~/.vim/bundle/ctrlp.vim                                                                    
set rtp+=~/.vim/bundle/minibufexpl.vim                                                              
set rtp+=~/.vim/bundle/nerdcommenter                                                                
set rtp+=~/.vim/bundle/nerdtree                                                                     
set rtp+=~/.vim/bundle/syntastic                                                                    
set rtp+=~/.vim/bundle/ultisnips                                                                    
set rtp+=~/.vim/bundle/vim-fugitive                                                                 
set rtp+=~/.vim/bundle/screen                                                                       
set rtp+=~/.vim/bundle/kdb-vim                                                                      
set rtp+=~/.vim/bundle/statquantPlugin                                                              
                                            
filetype plugin on                                                                                  
filetype indent on                                                                                  
syntax   on   

When I try to open a *q file the filetype is not detected. Then I commented out

if exists("did_load_filetypes")
  finish
endif 

So there the file is detected but then when I start writting some stuff and reopen the file the filetype swith to CONF. I need it as I statquantPlugin I configured something to act based on the filetype.

NOTE: I do not have access to the $VIM directory files

What can I do to have the filetype right ? Regards

I changed

$ cat .vim/bundle/kdb-vim/ftdetect/myFiletype.vim 
" my filetype file
"if exists("did_load_filetypes")
"  finish
"endif
"augroup filetypedetect
  au! BufRead,BufNewFile *.k            setfiletype k
  au! BufRead,BufNewFile *.q            setfiletype q
  au! BufRead,BufNewFile *.s            setfiletype sql
"augroup END

NOW working

2
  • What's with all those runtimepath modifications? Commented Dec 3, 2013 at 16:38
  • I am behind a firewall so I can't do BundleInstall => I took the .vim directory from somewhere else (where I could run BundleInstall), so I have to add the bundles to the rtp (well at least if I do not it does not work) Commented Dec 3, 2013 at 18:57

1 Answer 1

3

filetype.vim is the main filetype detection script; you shouldn't override it. Instead, put (only the au! BufRead,BufNewFile lines, the include guard and :augroup isn't necessary there) this into a file ~/.vim/bundle/kdb-vim/ftdetect/myfiletypes.vim. See :help ftdetect.

Sign up to request clarification or add additional context in comments.

1 Comment

Drop the :if exists(...), too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.