Skip to main content

auto-formatter for modern fortran source code

Project description

License: GPL v3

fprettify is an auto-formatter for modern Fortran code that imposes strict whitespace formatting.

Features

  • Auto-indentation.
  • Line continuations are aligned with the previous opening delimiter (, [ or (/ or with an assignment operator = or =>. If none of the above is present, a default hanging indent is applied.
  • Consistent amount of whitespace around operators and delimiters.
  • Removal of extraneous whitespace and consecutive blank lines.
  • Works only for modern Fortran (Fortran 90 upwards).
  • Tested for editor integration.
  • By default, fprettify causes changes in the amount of whitespace only and thus preserves revision history.

Example

program demo
integer :: endif,if,else
endif=3; if=2
if(endif==2)then
endif=5
else=if+4*(endif+&
2**10)
else if(endif==3)then
print*,endif
endif
end program

⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩ fprettify ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩

program demo
   integer :: endif, if, else
   endif = 3; if = 2
   if (endif == 2) then
      endif = 5
      else = if + 4*(endif + &
                     2**10)
   else if (endif == 3) then
      print *, endif
   endif
end program

Usage

Autoformat file1, file2, … inplace by

fprettify file1, file2, ...

The default indent is 3. If you prefer something else, use --indent n argument. For more options, read

fprettify -h

For editor integration, use

fprettify --silent

For instance, with Vim, use fprettify with gq by putting the following commands in your .vimrc:

autocmd Filetype fortran setlocal formatprg=fprettify\ --silent

Project details


Release history Release notifications

This version
History Node

0.3.1

History Node

0.3

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
fprettify-0.3.1-py2.7.egg (35.0 kB) Copy SHA256 hash SHA256 Egg 2.7 Jan 2, 2017
fprettify-0.3.1-py2.py3-none-any.whl (19.2 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jan 2, 2017
fprettify-0.3.1.tar.gz (15.2 kB) Copy SHA256 hash SHA256 Source None Jan 2, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page