How to get proper text-color-highlighting for Fortran 90 in Sublime Text 2?

19,580

Solution 1

The plugin at the fortran.tmBundle works for me. I created a Fortran subfolder in Packages and put all the files in the tmBundle there (not just the .tmLanguage files). It selects Fortran - Punchcard as the default type for .for and Fortran - Modern for .f90 files. These both treat ! just fine on my system - what problem are you having?

Solution 2

I also use Fortran (Modern) with Sublime Text (now I'm using version 3) and there was just a little glitch handling comments. Look at this example:

As you can see, the second line starts with an exclamation mark, but it's not recognized. But if I start the first line with "! " (including a space), then everything works:

If I put a dash after the ! of the second line, it reconizes it as a comment, but the problem goes to the third line:

I don't understand the language of the syntax file, but I've looked at the MinimalFortran package to fix this (this package works great and can be installed using Package Control, but it misses lots of syntaxes). I just changed the

<string>!-</string>

to

<string>[!]</string>

on the "Fortran - Modern.tmLanguage" file and it all worked:

Solution 3

Also check out Minimal Fortran. Been using it for a couple of months and can vouch for it. Easy to install using Package Control as well.

Share:
19,580

Related videos on Youtube

Timur B
Author by

Timur B

bazhirov.com

Updated on June 12, 2022

Comments

  • Timur B
    Timur B almost 2 years

    There are a couple of links on sublime forum, on how to get Sublime Text 2 to work with Fortran 90 here http://www.sublimetext.com/forum/viewtopic.php?f=4&t=770, but they don't quite seem to work as the comment identifier "!" is not treated well.

    I quickly assembled a solution using the original suggested Punchcard.tmLanguage file and modifying the first block in dictionary to treat "!" as comment (available here: https://gist.github.com/4209445).

    Sublime Text 2 is a great text editor and having it support Fortran might be helpful for many people in Theoretical physics and Finance. So if anyone knows a better solution, please let me know.

    Thanks!

  • Timur B
    Timur B over 11 years
    Thanks! I used .tmLanguage files only, that was the problem.
  • bananafish
    bananafish over 11 years
    Happy to help! Please accept the answer (the tick mark next to the arrow) if it solved your problem.
  • Girardi
    Girardi about 10 years
    the Packages folder can be accessed through menu Preferences>Browse packages