For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2005 > vim syntax highlighting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author vim syntax highlighting
Bart Vandewoestyne

2005-08-16, 5:06 pm

I have this strange, annoying vim synatx-highlighting problem and I was
wondering if others have also experienced that.

My setup is:

* VIM - Vi IMproved 6.3 (2004 June 7, compiled Apr 24 2005 15:54:11)

* My system is a stable Debian GNU/Linux box

* I have the following in my .vimrc

<<<<<<<<<<<<<<< BEGIN OF .vimrc >>>>>>>>>>>>
syntax enable
set visualbell
set autoindent
set shiftwidth=4

" show linenumbers
"set number

" might loose auto-intendation with this...
set paste

"linewrap at 72
set textwidth=72

:map <F10> :set paste<CR>
:map <F11> :set nopaste<CR>
:imap <F10> <C-O>:set paste<CR>
:imap <F11> <nop>
:set pastetoggle=<F11>
<<<<<<<<<<<<<<<<<<<<<<<<<< END OF .vimrc >>>>>>>>>>>>>>>>>

Now it sometimes happens that a standard conforming .f95 file for which
the syntax is definitely ok doesn't have the proper syntax highlighting... the
highlighting is all mixed up and is completely wrong.

Most of the times, these files have a number of comment lines, and deleting
some lines in the comments solves the problem. Unfortunately, I haven't been
able to trim done one of my files to a simple example because it's difficult
to know what exactly can be deleted from the comments in order to keep the
incorrect highligting... and up until now the .f95 files I am having problems
with should not be released to the public yet so I can't put them online :-(

I was just wondering if others have experienced the same problem, and maybe
have a trimmed down .f95 file with such a highlighting problem... so it could
possibly be sent as a bug-example to the vim-people...

If i succeed in trimming down one of my files to a simple testcase, I'll
definitely post it, but for now, if someone already has experienced the same
problem I would be glad to hear I'm not alone on this world with that
problem :-)

Regards,
Bart

--
"Share what you know. Learn what you don't."
John Mansell

2005-08-16, 5:06 pm

I've got a strangely-coloured display with the Win32 version, so I guess
that the feature is portable. Large expanses of pink, as if in a
character string. It seems to turn itself off when a spare quote mark is
found. To the best of my knowledge, I dont't have a startup file.

In message <1124194840.394636@seven.kulnet.kuleuven.ac.be>, Bart
Vandewoestyne <MyFirstName.MyLastName@telenet.be> writes
>I have this strange, annoying vim synatx-highlighting problem and I was
>wondering if others have also experienced that.
>
>My setup is:
>
>* VIM - Vi IMproved 6.3 (2004 June 7, compiled Apr 24 2005 15:54:11)
>
>* My system is a stable Debian GNU/Linux box
>
>* I have the following in my .vimrc
>
><<<<<<<<<<<<<<< BEGIN OF .vimrc >>>>>>>>>>>>
>syntax enable
>set visualbell
>set autoindent
>set shiftwidth=4
>
>" show linenumbers
>"set number
>
>" might loose auto-intendation with this...
>set paste
>
>"linewrap at 72
>set textwidth=72
>
>:map <F10> :set paste<CR>
>:map <F11> :set nopaste<CR>
>:imap <F10> <C-O>:set paste<CR>
>:imap <F11> <nop>
>:set pastetoggle=<F11>
><<<<<<<<<<<<<<<<<<<<<<<<<< END OF .vimrc >>>>>>>>>>>>>>>>>
>
>Now it sometimes happens that a standard conforming .f95 file for which
>the syntax is definitely ok doesn't have the proper syntax highlighting... the
>highlighting is all mixed up and is completely wrong.
>
>Most of the times, these files have a number of comment lines, and deleting
>some lines in the comments solves the problem. Unfortunately, I haven't been
>able to trim done one of my files to a simple example because it's difficult
>to know what exactly can be deleted from the comments in order to keep the
>incorrect highligting... and up until now the .f95 files I am having problems
>with should not be released to the public yet so I can't put them online :-(
>
>I was just wondering if others have experienced the same problem, and maybe
>have a trimmed down .f95 file with such a highlighting problem... so it could
>possibly be sent as a bug-example to the vim-people...
>
>If i succeed in trimming down one of my files to a simple testcase, I'll
>definitely post it, but for now, if someone already has experienced the same
>problem I would be glad to hear I'm not alone on this world with that
>problem :-)
>
>Regards,
>Bart
>


--
John Mansell john at wcompsys dot co dot uk

Kamaraju Kusumanchi

2005-08-16, 5:06 pm

Bart Vandewoestyne wrote:
> I have this strange, annoying vim synatx-highlighting problem and I was
> wondering if others have also experienced that.


> Now it sometimes happens that a standard conforming .f95 file for which
> the syntax is definitely ok doesn't have the proper syntax highlighting... the
> highlighting is all mixed up and is completely wrong.
>
> Most of the times, these files have a number of comment lines, and deleting
> some lines in the comments solves the problem. Unfortunately, I haven't been
> able to trim done one of my files to a simple example because it's difficult
> to know what exactly can be deleted from the comments in order to keep the
> incorrect highligting... and up until now the .f95 files I am having problems
> with should not be released to the public yet so I can't put them online :-(
>


I am suspecting that you are seeing syntax highlighting meant for .f77
files. For more details see

:help fortran

raju
Bart Vandewoestyne

2005-08-16, 5:06 pm

On 2005-08-16, Kamaraju Kusumanchi <kk288@cornell.edu> wrote:
>
> I am suspecting that you are seeing syntax highlighting meant for .f77
> files.


It sure looks something like that yes... but it's really not giving a
clean overview of the code in that way...

>For more details see
>
>:help fortran


Thanks! Adding

let fortran_free_source=1

to my .vimrc solved my problem. Apparently, for two of my files my
vim interpreted them as fixed source form files. However, i still find
it strange that most of my files get interpreted correctly as free
source form files, but only two of them get falsly interpreted and get
fixed source form... strange...

Regards,
Bart

--
"Share what you know. Learn what you don't."
Kamaraju Kusumanchi

2005-08-16, 5:06 pm

Bart Vandewoestyne wrote:
> On 2005-08-16, Kamaraju Kusumanchi <kk288@cornell.edu> wrote:
>
>
>
> Thanks! Adding
>
> let fortran_free_source=1
>
> to my .vimrc solved my problem. Apparently, for two of my files my
> vim interpreted them as fixed source form files. However, i still find
> it strange that most of my files get interpreted correctly as free
> source form files, but only two of them get falsly interpreted and get
> fixed source form... strange...


Let's say the problematic file is named as file1.txt . Is it happening
when you read the file afresh (say by doing vim file1.txt)? or when
reading it internally from vim ( say by doing vim somfile.txt and then
:e file1.txt)?



FYI, I have the following lines in my .vimrc

let s:extfname = expand("%:e")
if s:extfname ==? "f90"
let fortran_free_source=1
unlet! fortran_fixed_source
else
let fortran_fixed_source=1
unlet! fortran_free_source
endif

In this case, only if the extension is .f90 then 'free source' syntax
highlighting is used other wise 'fixed source' syntax highlighting will
be used.

hth
raju
Bart Vandewoestyne

2005-08-17, 9:14 am

On 2005-08-16, Kamaraju Kusumanchi <kk288@cornell.edu> wrote:
>
> [...]
>
> FYI, I have the following lines in my .vimrc
>
> let s:extfname = expand("%:e")
> if s:extfname ==? "f90"
> let fortran_free_source=1
> unlet! fortran_fixed_source
> else
> let fortran_fixed_source=1
> unlet! fortran_free_source
> endif
>
> In this case, only if the extension is .f90 then 'free source' syntax
> highlighting is used other wise 'fixed source' syntax highlighting will
> be used.


I have changed this to

let s:extfname = expand("%:e")
if (s:extfname ==? "f90") || (s:extfname ==? "f95")
let fortran_free_source=1
unlet! fortran_fixed_source
else
let fortran_fixed_source=1
unlet! fortran_free_source
endif


Now I have a few questions on this:

* is it really necessary to have a variable name `s:extfname' for the extension? does the `s:' have a special meaning?

* would it be possible to shorten the second line to something that says
`if the extension is within one of these strings, then ...'
So something like
if (s:extfname in {"f90", "f95"})

Sorry if this is going off-topic, but I thought others might also benefit from
this so i left it.

Regards,
Bart

--
"Share what you know. Learn what you don't."
Kamaraju Kusumanchi

2005-08-17, 9:15 am

Bart Vandewoestyne wrote:
> On 2005-08-16, Kamaraju Kusumanchi <kk288@cornell.edu> wrote:
>
>
>
> I have changed this to
>
> let s:extfname = expand("%:e")
> if (s:extfname ==? "f90") || (s:extfname ==? "f95")
> let fortran_free_source=1
> unlet! fortran_fixed_source
> else
> let fortran_fixed_source=1
> unlet! fortran_free_source
> endif
>
>
> Now I have a few questions on this:
>
> * is it really necessary to have a variable name `s:extfname' for the extension? does the `s:' have a special meaning?


Yes. s stands for script and s:var defines var to be local to that
particular script. For more details see :help s:var


>
> * would it be possible to shorten the second line to something that says
> `if the extension is within one of these strings, then ...'
> So something like
> if (s:extfname in {"f90", "f95"})
>


I dont know how to do this. I am not an expert in writing vim scripts.
May be others will help you in this area.

regards
raju
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com