VSCode
Integrate codee format with Visual Studio Code to format Fortran code.
Prerequisites
Ensure you have:
codeeinstalled and accessible from your command line.- Visual Studio Code installed on your system. This guide has been tested with v1.96.4.
- Basic familiarity with VSCode's interface and settings.
Install Fortran language support
Visual Studio Code requires additional extensions to work with Fortran files.
We recommend installing the official Modern Fortran
extension developed by fortran-lang.
Alternatively, you can choose other Fortran extensions. However, this guide
assumes you have Modern Fortran installed and enabled.
Install Custom Local Formatters
Additionally, install the Custom Local Formatters
extension to connect VSCode with codee format.
Configure Custom Local Formatters for codee format
Next, we need to configure Custom Local Formatters to use codee format for
Fortran files:
- Go to
File-->Preferences-->Settingsin VSCode. - Expand
Extensionsand selectCustom Local Formatters. - Click
Edit in settings.json.

- Add or merge the following configuration into your
settings.json:
{
"customLocalFormatters.formatters": [
{
"command": "codee format -",
"languages": [
"FortranFreeForm",
"FortranFixedForm"
],
}
],
}
Set codee format as the default formatter
To make codee format your default Fortran formatter:
- Create or open a
.f90file. - Right-click inside the editor and select
Format Document With.... - Choose
Configure Default Formatter. - Select
Custom Local Formattersto usecodee format.
Repeat these steps with a .f file if you also work with fixed-form Fortran.
Alternative way using Modern Fortran
Codee format integration with VSCode can also be done using only the Modern Fortran
extension tricking it into thinking that codee format is findent or fprettify.
This can be done with a simple script named 'findent' with the following content:
#!/bin/sh
"<full path to codee>/bin/codee" format - -o - "${@}"
Finally you need to add the following to your VSCode config file in the Fortran section:
"fortran.formatting.path": "<path to the findent script folder>"
Usage tips
You can now format Fortran files in VSCode with codee format:
- Right-click inside the editor and select
Format Document.
Additionally, VSCode offers the option to automatically format your Fortran
files whenever you save a file. If you are interested in enabling this feature,
search for the Format On Save option in the VSCode settings:

Troubleshoothing
If you encounter issues with codee format:
-
Ensure
codeeis properly installed and accessible from the command line. -
If you use a full path in
settings.json, verify it is correct. -
If
Custom Local Formattersdoes not appear as a formatting option for Fortran, verify thelanguagessection insettings.json. -
Add
--verboseto thesettings.jsoncommand to view debug information ofcodee formatunderOutput-->Custom Local Formatter.