On 2012-12-20, analogsix wrote:
> result of running that command is:
> filetype=
> 
> You hit the nail on the head. Namely, when the buffer(s) are first
> loaded onto gVIM, the filetype(s) aren't recognized (as we can see
> the 'filetype' option is set to blank).
> 
> As a quick fix to get gVIM to properly load and recognize my *.sv
> files, I've entered the following in my .gvimrc file: au
> BufNewFile,BufRead *sv,*svi setf verilog Now when I load new or
> toggle existing buffers, syntax coloring works fine.
> 
> Going back to the stated problem. How do I explain how the
> file1.sv syntax was correctly identified and syntax-colored by VIM
> when initially loaded? Well, my own answer comes from something I
> recall reading the help file from ":help syntax". I read somewhere
> in that {m,h}aze of a help file, that during the syntax-loading
> procedure, if VIM fails at loading syntax settings via its
> conventional syntax-loading procedure, it scans the file to
> identify what syntax settings to apply. I guess this VIM feature
> only works on `loading` ONE new file from the command-line or
> gVIM, and not on loading multiple new buffers (from the
> command-line) nor on toggling VIM window views between non-active
> buffers.

Something doesn't add up here.  Syntax files are named according to
the filetype, so for example ft=sh results in the loading of
syntax/sh.vim.  If 'ft' is empty, then Vim has no filetype from
which to construct a syntax file name.

Here's the procedure you were referring to:

$VIMRUNTIME/filetype.vim defines a set of rules for determining a
file's filetype from its suffix or extension.  If that fails, Vim
tries to determine the filetype from the file's content according to
the rules in $VIMRUNTIME/scripts.vim.  (That's a simplification, but
close enough for now.)

Still, Vim cannot automatically apply syntax highlighting without a
filetype.

You might try this command,

    :echo b:current_syntax

to see the name of the syntax currently in effect, or rather, last
applied, and this command

    :scriptnames

to see which scripts, including syntax highlighting files, have been
sourced.

Those may shed some light on which syntax highlighting you're seeing
and how it was set.

One other thing:  If you're sure of what you're doing, you can put
filetype-detection autocommands any place you like.  If you're not
sure though, or if you're having difficulty getting things working
the way you think they should, you should probably stick to the
recommended methods for filetype detection described in ":help
new-filetype".  The method described under ":help ftdetect" is
probably the simplest.

Regards,
Gary

-- 
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

Reply via email to