Quantcast

Syntax Highlighting works for one file only

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Syntax Highlighting works for one file only

Tim Johnson-3
Hello:
I'm using vim compiled as 'vim.full' for kubuntu 7.04 amd-64.
I can load one file and one file only - it's a python file - where
syntax highlighting comes on automatically. Any subsequent
files with a .py extension are loaded with only strings highlighted.
:setf python enables full highlighting

I'm baffled. I've rebuilt .vimrc and .gvimrc one line at a time
and I see nothing that could be causing this.

Any and all help would be appreciated.
Thanks
Tim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Syntax Highlighting works for one file only

A.J.Mechelynck
Tim Johnson wrote:

> Hello:
> I'm using vim compiled as 'vim.full' for kubuntu 7.04 amd-64.
> I can load one file and one file only - it's a python file - where
> syntax highlighting comes on automatically. Any subsequent
> files with a .py extension are loaded with only strings highlighted.
> :setf python enables full highlighting
>
> I'm baffled. I've rebuilt .vimrc and .gvimrc one line at a time
> and I see nothing that could be causing this.
>
> Any and all help would be appreciated.
> Thanks
> Tim
>

In your second (badly highlighted) *.py file, what does Vim answer to

        :verbose set filetype?

?


Best regards,
Tony.
--
VIRGO (Aug 23 - Sept 22)
        You are the logical type and hate disorder.  This nitpicking is
        sickening to your friends.  You are cold and unemotional and
        sometimes fall asleep while making love.  Virgos make good bus
        drivers.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Syntax Highlighting works for one file only

Tim Johnson-3
On Tuesday 05 June 2007, A.J.Mechelynck wrote:
 
> In your second (badly highlighted) *.py file, what does Vim answer to
>
> :verbose set filetype?
>
 filetype=conf
        Last set from /usr/share/vim/vim70/filetype.vim
Hmm!
Thanks Tony
Tim

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Syntax Highlighting works for one file only

A.J.Mechelynck
Tim Johnson wrote:

> On Tuesday 05 June 2007, A.J.Mechelynck wrote:
>  
>> In your second (badly highlighted) *.py file, what does Vim answer to
>>
>> :verbose set filetype?
>>
>  filetype=conf
>         Last set from /usr/share/vim/vim70/filetype.vim
> Hmm!
> Thanks Tony
> Tim
>
>  
>
>

Hm. In the Vim 7.1 filetype.vim, filetype "conf" is set for any file, one of
the first 5 lines of which starts with #, but only if everything else fails
(and *.py is detected as type "python" before that...)

I wonder what causes your first *.py, but not the others, to be detected as
python.


Best regards,
Tony.
--
"I have the world's largest collection of seashells.  I keep it
scattered around the beaches of the world ... Perhaps you've seen it.
                -- Steven Wright
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Syntax Highlighting works for one file only

Tim Johnson-3
On Tuesday 05 June 2007, you wrote:
 
> Hm. In the Vim 7.1 filetype.vim, filetype "conf" is set for any file, one
> of the first 5 lines of which starts with #, but only if everything else
> fails (and *.py is detected as type "python" before that...)
>
> I wonder what causes your first *.py, but not the others, to be detected as
> python.
   The first file, the one that got good syntax highlighting, did not have
    a she-bang line, others did not.
I'm having a similar problem:
I also program with a language called rebol.
filetype.vim does not properly "understand" how rebol works.
Here is the original code:
 " Rexx, Rebol or R
  au BufNewFile,BufRead *.r,*.R           call s:FTr()

  fun! s:FTr()
    if getline(1) =~ '^REBOL'
      setf rebol
    else
      let n = 1
      let max = line("$")
      if max > 50
        let max = 50
      endif
      while n < max
        " R has # comments
        if getline(n) =~ '^\s*#'
      setf r
      break
        endif
        " Rexx has /* comments */
        if getline(n) =~ '^\s*/\*'
      setf rexx
      break
        endif
        let n = n + 1
      endwhile
      if n >= max
        setf rexx
      endif
    endif
  endfun
# it is incomplete because a rebol file may
1)begin with the regex "REBOL" in either lower or upper or mixed case
2)begin with a shebang line containing "rebol"
3)furthermore, in some cases neither condition would be present.

Thus, I found that any rebol file *without* the shebang line highlighted
properly, but with the shebang line, needed :setf rebol

Now here is what is weird:
I changed the code in filetype to the following simpler approach:
au BufNewFile,BufRead *.r,*.R,*.reb         setf rebol
removing function FTr entirely
but the same symptoms remain.

I would suspect that there is a side effect from some other file
that is sourced. When I get more time, I will remove files from
~/.vim/plugin , ... autoload etc and see what happens as I add
them back in. In the meantime, this highly annoying but not a
crisis, after all setf does the job.

thanks for looking into this,
I'd welcome other comments all the same.
regards
tim


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Syntax Highlighting works for one file only

Tim Johnson-3
In reply to this post by A.J.Mechelynck
On Tuesday 05 June 2007, A.J.Mechelynck wrote:

> Tim Johnson wrote:
> > Hello:
> > I'm using vim compiled as 'vim.full' for kubuntu 7.04 amd-64.
> > I can load one file and one file only - it's a python file - where
> > syntax highlighting comes on automatically. Any subsequent
> > files with a .py extension are loaded with only strings highlighted.
> >
> > :setf python enables full highlighting
> >
> > I'm baffled. I've rebuilt .vimrc and .gvimrc one line at a time
> > and I see nothing that could be causing this.
   Just for a quick test, I changed the name of the .vim
   directory. The symptoms that I described vanished.
   It would seem to be in the plugin or autoload directories.
   I've got some *old* vim scripts in there ....
tim
Loading...