Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fortran 90/95 syntax highlighting in NEdit 5.5 ?

430 views
Skip to first unread message

Bart Vandewoestyne

unread,
Jun 16, 2009, 4:26:40 AM6/16/09
to
I'm trying to get colored syntax highlighting to work in NEdit
5.5 (Sep 30, 2004) (for a collegue of mine).

I added .f90 and .f95 to the File extensions under

Preferences -> Default Settings -> Language Modes -> Fortran

but all I get is some black/white/italic syntax highlighting, no
colours at all.

Does anybody in this group has experience with colored syntax
highlighting for Fortran 90/95 code in NEdit?

Thanks,
Bart

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

Carlie Coats

unread,
Jun 16, 2009, 7:08:25 AM6/16/09
to
Bart Vandewoestyne wrote:
> I'm trying to get colored syntax highlighting to work in NEdit
> 5.5 (Sep 30, 2004) (for a collegue of mine).
>
> I added .f90 and .f95 to the File extensions under
>
> Preferences -> Default Settings -> Language Modes -> Fortran
>
> but all I get is some black/white/italic syntax highlighting, no
> colours at all.
>
> Does anybody in this group has experience with colored syntax
> highlighting for Fortran 90/95 code in NEdit?
>
> Thanks,
> Bart
>

Check with nedit.org: from _someone_ (there, I think) I got the set
of f90 highlight patterns below.

-- Carlie Coats

--------------- cut here for extract from nedit.rc -------------
nedit.highlightPatterns:
Fortran90:1:30{\n\
Comment:"!":"$"::Comment::\n\
Continuation:"&":::Flag::\n\
String:"'":"'":"\\n([^ \\t]| [^ \\t]| [^ \\t]| [^ \\t]| [^ \\t]|
[ \\t0]| *\\t[^1-9])":String::\n\

Keywords:"<(ACCEPT|[Aa]ccept|ASSIGN|[Aa]ssign|AUTOMATIC|[Aa]utomatic|BACKSPACE|[Bb]ackspace|BLOCK|[Bb]lock|CALL|[Cc]all|CLOSE|[Cc]lose|COMMON|[Cc]ommon|CONTINUE|[Cc]ontinue|DATA|[Dd]ata|DECODE|[Dd]ecode|DELETE|[Dd]elete|DIMENSION|[Dd]imension|DO|[Dd]o|ELSE|[Ee]lse|ELSEIF|[Ee]lseif|ENCODE|[Ee]ncode|END
*FILE|[Ee]nd
*[Ff]ile|ENDFILE|[Ee]ndfile|END|[Ee]nd|ENDIF|[Ee]ndif|ENTRY|[Ee]ntry|EQUIVALENCE|[Ee]quivalence|EXIT|[Ee]xit|EXTERNAL|[Ee]xternal|FORMAT|[Ff]ormat|FUNCTION|[Ff]unction|GOTO|[Gg]oto|IF|[Ii]f|IMPLICIT|[Ii]mplicit|INCLUDE|[Ii]nclude|INQUIRE|[Ii]nquire|INTRINSIC|[Ii]ntrinsic|LOGICAL|[Ll]ogical|MAP|[Mm]ap|NONE|[Nn]one|ON|[Oo]n|OPEN|[Oo]pen|PARAMETER|[Pp]arameter|PAUSE|[Pp]ause|POINTER|[Pp]ointer|PRINT|[Pp]rint|PROGRAM|[Pp]rogram|READ|[Rr]ead|RECORD|[Rr]ecord|RETURN|[Rr]eturn|REWIND|[Rr]ewind|SAVE|[Ss]ave|STATIC|[Ss]tatic|STOP|[Ss]top|STRUCTURE|[Ss]tructure|SUBROUTINE|[Ss]ubroutine|SYSTEM|[Ss]ystem|THEN|[Tt]hen|TO|[Tt]o|TYPE|[Tt]ype|UNION|[Uu]nion|UNLOCK|[Uu]nlock|VIRTUAL|[Vv]irtual|VOLATILE|[Vv]olatile|WHILE|[Ww]hile|WRITE|[Ww]rite)>":::Keyword::D\n\
Data
Types:"<(BYTE|[Bb]yte|CHARACTER|[Cc]haracter|COMPLEX|[Cc]omplex|DOUBLE
*COMPLEX|[Dd]ouble *[Cc]omplex|DOUBLE *PRECISION|[Dd]ouble
*[Pp]recision|DOUBLE|[Dd]ouble|INTEGER|[Ii]nteger|REAL|[Rr]eal)(\\*[0-9]+)?>":::Keyword::D\n\
F90
Keywords:"<(ALLOCATABLE|[Aa]llocatable|ALLOCATE|[Aa]llocate|CASE|[Cc]ase|CASE|[Cc]ase|CONTAINS|[Cc]ontains|CYCLE|[Cc]ycle|DEALLOCATE|[Dd]eallocate|ELSEWHERE|[Ee]lsewhere|ENDWHERE|[Ee]ndwhere|INTENT|[Ii]ntent|INTERFACE|[Ii]nterface|MODULE|[Mm]odule|NAMELIST|[Nn]amelist|OPTIONAL|[Oo]ptional|PRIVATE|[Pp]rivate|PROCEDURE|[Pp]rocedure|PUBLIC|[Pp]ublic|REWRITE|[Rr]ewrite|SELECT|[Ss]elect|USE|[Uu]se|WHERE|[Ww]here)>":::Keyword::D\n\
Numeric
const:"<[0-9]+(\\.[0-9]*)?([DEde][-+]?[0-9]*)?|\\.[0-9]+([DEde][-+]?[0-9]*)?>":::Numeric
Const::D\n\
}\n\
nedit.languageModes:
Fortran90:.f90 .F90:::None::::\n\

Paul van Delst

unread,
Jun 16, 2009, 1:12:45 PM6/16/09
to

And, just for grins, here's what I use to comment/uncomment blocks of Fortran code in my
nedit.rc:

Comment@Fortran:Alt+1::: {\n\
if ($selection_start == -1) {\n\
cur = $cursor\n\
beginning_of_line()\n\
select($cursor, $cursor + 1)\n\
replace_in_selection("^", "!", "regex")\n\
set_cursor_pos(cur)\n\
select(-1,-1)\n\
# replace_all("^", "!", "regex")\n\
}\n\
else\n\
replace_in_selection("^", "!", "regex")\n\
}\n\
Uncomment@Fortran:Shift+Alt+1::: {\n\
if ($selection_start == -1) {\n\
cur = $cursor\n\
beginning_of_line()\n\
select($cursor, $cursor + 1)\n\
replace_in_selection("^!", "", "regex")\n\
set_cursor_pos(cur)\n\
select(-1,-1)\n\
# replace_all("^!", "", "regex")\n\
}\n\
else\n\
replace_in_selection("^!", "", "regex")\n\
}\n\

Select a block of text and "Alt+1" sticks a "!" in col 1. Shift+Alt+1 uncomments the block.

cheers,

paulv

dioso...@gmail.com

unread,
Mar 1, 2018, 5:55:40 AM3/1/18
to
This works like a charm (from http://ftp.vim.org/editors/NEdit/contrib/highlighting/f90.pats, with a small correction - : added at the end)

! Fortran 90 Syntax Highlighting Patterns
! (submitted by Van Snyder <vsnyder.at.math.jpl.nasa.gov>)
!
! In NEdit Version 5.0.1 and beyond, load this pattern by starting nedit with:
!
! nedit -import <name of this file>
!
! Then, check that the patterns were loaded correctly, and choose Save Defaults
! from the Preferences menu. The new patterns will now be incorporated into
! your own .nedit file, so the next time you start NEdit, you will no longer
! need to use -import.
!
! In version 5.0, without -import, you must edit your .nedit file by hand and
! add the contents of each resource below to the corresponding list in your
! .nedit file. Be sure to separate new entries with \n, and continue resource
! strings by escaping all newlines within a resource value with \ (backslash),
! leaving only the last line of the resource value not ending in \.
!
nedit.highlightPatterns: \
Fortran90:1:30{\n\
Comment:"!":"$"::Comment::\n\
Continuation:"&":::Flag::\n\
String:"'":"'":"\\n([^ \\t]| [^ \\t]| [^ \\t]| [^ \\t]| [^ \\t]| [ \\t0]| *\\t[^1-9])":String::\n\
Keywords:"<(ACCEPT|[Aa]ccept|ASSIGN|[Aa]ssign|AUTOMATIC|[Aa]utomatic|BACKSPACE|[Bb]ackspace|BLOCK|[Bb]lock|CALL|[Cc]all|CLOSE|[Cc]lose|COMMON|[Cc]ommon|CONTINUE|[Cc]ontinue|DATA|[Dd]ata|DECODE|[Dd]ecode|DELETE|[Dd]elete|DIMENSION|[Dd]imension|DO|[Dd]o|ELSE|[Ee]lse|ELSEIF|[Ee]lseif|ENCODE|[Ee]ncode|END *FILE|[Ee]nd *[Ff]ile|ENDFILE|[Ee]ndfile|END|[Ee]nd|ENDIF|[Ee]ndif|ENTRY|[Ee]ntry|EQUIVALENCE|[Ee]quivalence|EXIT|[Ee]xit|EXTERNAL|[Ee]xternal|FORMAT|[Ff]ormat|FUNCTION|[Ff]unction|GOTO|[Gg]oto|IF|[Ii]f|IMPLICIT|[Ii]mplicit|INCLUDE|[Ii]nclude|INQUIRE|[Ii]nquire|INTRINSIC|[Ii]ntrinsic|LOGICAL|[Ll]ogical|MAP|[Mm]ap|NONE|[Nn]one|ON|[Oo]n|OPEN|[Oo]pen|PARAMETER|[Pp]arameter|PAUSE|[Pp]ause|POINTER|[Pp]ointer|PRINT|[Pp]rint|PROGRAM|[Pp]rogram|READ|[Rr]ead|RECORD|[Rr]ecord|RETURN|[Rr]eturn|REWIND|[Rr]ewind|SAVE|[Ss]ave|STATIC|[Ss]tatic|STOP|[Ss]top|STRUCTURE|[Ss]tructure|SUBROUTINE|[Ss]ubroutine|SYSTEM|[Ss]ystem|THEN|[Tt]hen|TO|[Tt]o|TYPE|[Tt]ype|UNION|[Uu]nion|UNLOCK|[Uu]nlock|VIRTUAL|[Vv]irtual|VOLATILE|[Vv]olatile|WHILE|[Ww]hile|WRITE|[Ww]rite)>":::Keyword::D\n\
Data Types:"<(BYTE|[Bb]yte|CHARACTER|[Cc]haracter|COMPLEX|[Cc]omplex|DOUBLE *COMPLEX|[Dd]ouble *[Cc]omplex|DOUBLE *PRECISION|[Dd]ouble *[Pp]recision|DOUBLE|[Dd]ouble|INTEGER|[Ii]nteger|REAL|[Rr]eal)(\\*[0-9]+)?>":::Keyword::D\n\
F90 Keywords:"<(ALLOCATABLE|[Aa]llocatable|ALLOCATE|[Aa]llocate|CASE|[Cc]ase|CASE|[Cc]ase|CONTAINS|[Cc]ontains|CYCLE|[Cc]ycle|DEALLOCATE|[Dd]eallocate|ELSEWHERE|[Ee]lsewhere|ENDWHERE|[Ee]ndwhere|INTENT|[Ii]ntent|INTERFACE|[Ii]nterface|MODULE|[Mm]odule|NAMELIST|[Nn]amelist|OPTIONAL|[Oo]ptional|PRIVATE|[Pp]rivate|PROCEDURE|[Pp]rocedure|PUBLIC|[Pp]ublic|REWRITE|[Rr]ewrite|SELECT|[Ss]elect|USE|[Uu]se|WHERE|[Ww]here)>":::Keyword::D\n\
Numeric const:"<[0-9]+(\\.[0-9]*)?([DEde][-+]?[0-9]*)?|\\.[0-9]+([DEde][-+]?[0-9]*)?>":::Numeric Const::D\n\
}
nedit.languageModes: Fortran90:.f90:::::::

Mohammad

unread,
Mar 1, 2018, 2:21:52 PM3/1/18
to
I recommend using code::blocks, Notepad++ or VS Code instead of NEDIT. Take a look.

steve kargl

unread,
Mar 1, 2018, 2:55:57 PM3/1/18
to
Mohammad wrote:

> On Tuesday, June 16, 2009 at 3:38:25 PM UTC+4:30, Carlie Coats wrote:
>> Bart Vandewoestyne wrote:
>> > I'm trying to get colored syntax highlighting to work in NEdit
>> > 5.5 (Sep 30, 2004) (for a collegue of mine).
>> >
>> > I added .f90 and .f95 to the File extensions under
>> >
>> > Preferences -> Default Settings -> Language Modes -> Fortran
>> >
>> > but all I get is some black/white/italic syntax highlighting, no
>> > colours at all.
>> >
>> > Does anybody in this group has experience with colored syntax
>> > highlighting for Fortran 90/95 code in NEdit?
>> >
>>
>> Check with nedit.org: from _someone_ (there, I think) I got the set
>> of f90 highlight patterns below.
>>
>
> I recommend using code::blocks, Notepad++ or VS Code instead of NEDIT. Take a look.

Why? Nedit (and vi) work quite well with getting Fortran code written.

--
steve

Mohammad

unread,
Mar 1, 2018, 3:30:10 PM3/1/18
to
@Steve
Yes, these are feature rich alternatives with huge user community!

steve kargl

unread,
Mar 1, 2018, 4:36:03 PM3/1/18
to
I agree that nedit and vi are feature rich and have huge user
communities. So, why recommend an alternative?

--
steve

Mohammad

unread,
Mar 1, 2018, 11:26:37 PM3/1/18
to
I mean Code::Blocks not Nedit! Code::Blocks or Eclips are IDEs with much more capabilities, Photran also is another alternative like C::B but is younger!

Mohammad

unread,
Mar 1, 2018, 11:28:06 PM3/1/18
to
Eclipse == photran

Stefano Zaghi

unread,
Mar 2, 2018, 12:11:24 AM3/2/18
to
I used almost all editor/ide, codeblock included (emacs not).

In my modest opinion, no one is as effective as vim. Atom is the only one near to it (and emacs for "the other side of the moon"). Naturally, the choice of an editor is a very personal taste, but vim is very very powerful, although not simple to "dominate".

My 2 cents.

Cheers

Mohammad

unread,
Mar 2, 2018, 12:16:24 AM3/2/18
to
Thank you Stefano! That's quite true! the choice of editor/IDE is a matter of taste!

Thomas Koenig

unread,
Mar 2, 2018, 1:58:14 AM3/2/18
to
Stefano Zaghi <stefan...@gmail.com> schrieb:
> I used almost all editor/ide, codeblock included (emacs not).

> In my modest opinion, no one is as effective as vim.

My personal preference is emacs, because indentation works out of
the box for my Linux distro.

Indentation in the vim version that I use by default is simply
horrible.

I'm sure there are packages out there that work well. It might be
good to identify these and try to get them included with the
standard distibutions.

>Atom is the only one near to it (and emacs for "the other side of
>the moon"). Naturally, the choice of an editor is a very personal
>taste, but vim is very very powerful, although not simple to
>"dominate".

I used to use standard vi for programming, and use vim to write
this post. However, I have never gotten warm with the extra
featuers of vim, I tend to use it as a standard vi.

Stansfield Temmelmeier

unread,
Mar 2, 2018, 6:47:54 AM3/2/18
to
>> I recommend using code::blocks, Notepad++ or VS Code instead of NEDIT. Take a look.
>
> Why? Nedit (and vi) work quite well with getting Fortran code written.
>

Emacs is superb. The Fortran syntax highlighting support is so good I more
often than not catch bugs before I even compile the code.

Stan

Stansfield Temmelmeier

unread,
Mar 2, 2018, 6:49:35 AM3/2/18
to
On 2018-03-02, Thomas Koenig <tko...@netcologne.de> wrote:
> My personal preference is emacs, because indentation works out of
> the box for my Linux distro.

Ditto. And I would think on all Linux distros.

> I used to use standard vi for programming, and use vim to write
> this post. However, I have never gotten warm with the extra
> featuers of vim, I tend to use it as a standard vi.

I used emacs to write this post. I only use Vi when I bring up a new UNIX
box and haven't built Emacs from source yet.

Stan

Stefano Zaghi

unread,
Mar 2, 2018, 7:59:19 AM3/2/18
to
You are on the other side of the moon... Vim rocks!

:-)

Cheers

0 new messages