You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fprettify is an auto-formatter for modern Fortran code that imposes strict whitespace formatting.
5
+
fprettify is an auto-formatter for modern Fortran code that imposes strict whitespace formatting, written in Python.
5
6
6
7
7
8
## Features
8
9
9
10
* Auto-indentation.
10
11
* 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.
11
-
*All operators are surrounded by exactly one whitespace character, except for arithmetic operators.
12
+
*Consistent amount of whitespace around operators and delimiters.
12
13
* Removal of extraneous whitespace and consecutive blank lines.
13
14
* Works only for modern Fortran (Fortran 90 upwards).
15
+
* Tested for editor integration.
14
16
* By default, fprettify causes changes in the amount of whitespace only and thus preserves revision history.
17
+
* Feature missing? Please create an issue.
15
18
16
19
17
20
## Requirements
@@ -21,7 +24,35 @@ Python 2.7 or Python 3.x
21
24
22
25
## Examples
23
26
24
-
Compare `examples/*before.f90` (original Fortran files) with `examples/*after.f90` (reformatted Fortran files) to see what fprettify does.
27
+
Compare `examples/*before.f90` (original Fortran files) with `examples/*after.f90` (reformatted Fortran files) to see what fprettify does. A quick demonstration:
28
+
29
+
```Fortran
30
+
program demo
31
+
integer :: endif,if,else
32
+
endif=3; if=2
33
+
if(endif==2)then
34
+
endif=5
35
+
else=if+4*(endif+&
36
+
2**10)
37
+
else if(endif==3)then
38
+
print*,endif
39
+
endif
40
+
end program
41
+
```
42
+
⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩
43
+
```Fortran
44
+
program demo
45
+
integer :: endif, if, else
46
+
endif = 3; if = 2
47
+
if (endif == 2) then
48
+
endif = 5
49
+
else = if + 4*(endif + &
50
+
2**10)
51
+
else if (endif == 3) then
52
+
print *, endif
53
+
endif
54
+
end program
55
+
```
25
56
26
57
27
58
## Installation
@@ -43,7 +74,12 @@ The default indent is 3. If you prefer something else, use `--indent=<n>` argume
43
74
44
75
For editor integration, use
45
76
```
46
-
fprettify --no-report-errors
77
+
fprettify --silent
78
+
```
79
+
80
+
For instance, with Vim, use fprettify with `gq` by putting the following commands in your `.vimrc`:
0 commit comments