On Sun, Oct 15, 2006 at 11:37:33PM -0700, Kunapuli, Udaykumar wrote: > Hi, > > I am using VIM 7.0 on UNIX. I have files with extension .lib (*.lib > files). VIM automatically thinks that it is a Cobol filetype. The file > has nothing to do with Cobol. I have tried setting the following things > in my .vimrc. > > au BufNewFile,BufRead *.lib set ft=text > au BufNewFile,BufRead *.lib filetype off > au BufNewFile,BufRead *.lib filetype plugin indent off
The first line should be enough. The 'filetype' (abbreviated 'ft') option is local to the buffer and should be set each time you edit a *.lib buffer. The :filetype command is global. If you want to turn off all filetype detection, add the line filetype off to your vimrc file. I cannot think of any situation in which it makes sense to put it in a BufNewFile,BufRead autocommand. > I could take away the glaring syntax highlighting (red background on > all text!!!), but it was not of any help in terms of searching and > regular expression. > > In ordinary text files, underscore ("_") is considered as a legal part > of the word (or the regular expression \w). However in files with > extension .lib, VIM seems to consider underscore ("_") as a special > character. > > Is there anyway for me to make *.lib files to be treated as ordinary > text files by VIM for everything (syntax highlighting, indenting, > regular expression searching etc.)? The problem is that autocommands are executed in the order in which they are defined. Apparently, the autocommand in your vimrc file, setting ft=text, comes after the one that sets ft=cobol. Thus things happen in this order: :set ft=cobol :source $VIMRUNTIME/syntax/cobol.vim :setlocal isk=@,48-57,- :set ft=text and nothing undoes the 'iskeyword' setting. The simple solution is to make sure that your autocommand comes before any filetype on or source $VIMRUNTIME/vimrc_example.vim in your vimrc file. A more robust method (since it does not rely on the order of lines in your vimrc file) is to use either method A or C from :help new-filetype > I tried editing the filetype.vim in the runtime directory and > commenting the portion with the .lib extension. But it didn't work. That is not recommended. If you fix problems by editing things under $VIMRUNTIME, then you will have to remember to fix them each time you upgrade to a new version of vim. In the long run, it is easier to fix things in your own vim directory. > Thanks, > Uday HTH --Benji Fisher