On 11/02/11 11:57 AM, Dun Peal wrote:
On Feb 10, 5:25 pm, Ben Schmidt<[email protected]> wrote:
When you have a file open, what do you see if you do
:verbose set ft?
and
:verbose set syn?
Thanks, turns out the ft and syn were "conf". Some digging revealed
that Vim sets the ft (and consequently syn) to "conf" if the file
includes a line starting with # (which seems like an over-inclusive
heuristic).
What's the best way to deal with that? I have plenty of files (e.g.
markdown-formatted) that have # at the beginning of their lines but
are decidedly not "conf" files.
Mmm, yeah, that's a bit awkward. There are a number of ways to deal with
it. I think these are the three best ways:
To disable all heuristics just for .txt files, you could put this in
your .vimrc:
let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\|txt\)$'
This is based on $VIMRUNTIME/filetype.vim:40 where the same is found,
but without the txt.
Another way would be to get to .txt files before the other heuristic
does, as :help remove-filetype suggests. Put something like this in
~/.vim/filetype.vim:
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au BufRead,BufNewFile *.txt setfiletype disabled
augroup END
Then .txt files will never be highlighted.
Or you could target the one particular heuristic that is causing you
trouble by mimicking it, again in ~/.vim/filetype.vim (hopefully this
doesn't wrap wrongly; it's based on $VIMRUNTIME/filetype.vim:2492):
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
\ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
\ || getline(4) =~ '^#' || getline(5) =~ '^#') |
\ setf disabled |
\ endif
augroup END
That will effectively disable that heuristic for all file types, but
other heuristics will continue to work. By changing the * to *.txt you
could disable just that heuristic just for .txt files.
Hope this helps!
Ben.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php