diff --git a/src/browser.c b/src/browser.c
index 51ea37fa99b118a3073cd2eba6feba94e76726f4..df980795e5a08aa96867aaebaca7dbbfc09668a9 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -21,10 +21,10 @@
 
 #include "proto.h"
 
+#include <errno.h>
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
-#include <errno.h>
 
 #ifdef ENABLE_BROWSER
 
diff --git a/src/chars.c b/src/chars.c
index d2d87a38ab7f44cb8719aba1e102e1a4fa1ae58d..fa8457d007a6b9f645f6e5a2dbe503b14fd77dba 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -21,8 +21,8 @@
 
 #include "proto.h"
 
-#include <string.h>
 #include <ctype.h>
+#include <string.h>
 
 #ifdef ENABLE_UTF8
 #include <wchar.h>
diff --git a/src/color.c b/src/color.c
index fe925866defe06affde619e7be0a117c546c3fe2..e61e89aec3a665e90c255ff0ce8de4c9a6d94d0b 100644
--- a/src/color.c
+++ b/src/color.c
@@ -21,13 +21,12 @@
 
 #include "proto.h"
 
-#include <string.h>
 #include <errno.h>
-#include <unistd.h>
-
 #ifdef HAVE_MAGIC_H
 #include <magic.h>
 #endif
+#include <string.h>
+#include <unistd.h>
 
 #ifndef DISABLE_COLOR
 
diff --git a/src/files.c b/src/files.c
index 573c449a73b3b325b900bcfb06a50cf1ee99b346..1e4e4603826a1f47e87a49ffc8f7cb77ed68b91f 100644
--- a/src/files.c
+++ b/src/files.c
@@ -21,14 +21,14 @@
 
 #include "proto.h"
 
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
-#include <libgen.h>
+#include <string.h>
+#include <unistd.h>
 
 #define LOCKBUFSIZE 8192
 
diff --git a/src/help.c b/src/help.c
index 85ba6b514f30d7551748ecf9869c841c435c1c09..76181cdc470ad936c14d07c64c3a8f283ebba0ef 100644
--- a/src/help.c
+++ b/src/help.c
@@ -22,8 +22,8 @@
 
 #include "proto.h"
 
-#include <string.h>
 #include <errno.h>
+#include <string.h>
 
 #ifdef ENABLE_HELP
 
diff --git a/src/nano.c b/src/nano.c
index 1bb67761a67951d8591beeeddbf9f62d6d266361..935e07c43f50148b7735a5bdf79a0e4e4fe71769 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -22,22 +22,22 @@
 #include "proto.h"
 #include "revision.h"
 
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
 #include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#ifndef NANO_TINY
+#include <sys/ioctl.h>
+#endif
 #ifdef ENABLE_UTF8
 #include <langinfo.h>
 #endif
 #include <locale.h>
+#include <string.h>
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
-#include <getopt.h>
-#ifndef NANO_TINY
-#include <sys/ioctl.h>
-#endif
+#include <unistd.h>
 
 #ifdef ENABLE_MOUSE
 static int oldinterval = -1;
diff --git a/src/rcfile.c b/src/rcfile.c
index 74348f5bf343c660942c8786fb90c00f9f39df60..db9f6fba002ade529e8719cb76aa3727a79cf554 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -22,11 +22,11 @@
 
 #include "proto.h"
 
+#include <ctype.h>
+#include <errno.h>
 #include <glob.h>
 #include <string.h>
-#include <errno.h>
 #include <unistd.h>
-#include <ctype.h>
 
 #ifdef ENABLE_NANORC
 
diff --git a/src/text.c b/src/text.c
index ef3c80b1f088203b3a2d9d7207aeb626b507db1b..6fb72c2b6cef622c5f6f94a7f001e395ac6f9f94 100644
--- a/src/text.c
+++ b/src/text.c
@@ -24,11 +24,11 @@
 
 #include "proto.h"
 
-#include <unistd.h>
-#include <string.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/wait.h>
-#include <errno.h>
 
 #ifndef NANO_TINY
 static pid_t pid = -1;
diff --git a/src/utils.c b/src/utils.c
index f3000e5cae8ab2dea8168fed9bd27aa83d419fec..9cb53a41cc6f8e440c3a68d8f307ddddb95c9f1f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -21,12 +21,12 @@
 
 #include "proto.h"
 
-#include <string.h>
-#include <unistd.h>
+#include <errno.h>
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
-#include <errno.h>
+#include <string.h>
+#include <unistd.h>
 
 /* Return the user's home directory.  We use $HOME, and if that fails,
  * we fall back on the home directory of the effective user ID. */
diff --git a/src/winio.c b/src/winio.c
index e3aa12219085415eb92626a1ac66c6e54b31dfa8..31da93878182e172141d15290732e428ae88f1eb 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -22,12 +22,11 @@
 #include "proto.h"
 #include "revision.h"
 
+#include <ctype.h>
 #ifdef __linux__
 #include <sys/ioctl.h>
 #endif
-
 #include <string.h>
-#include <ctype.h>
 
 #ifdef REVISION
 #define BRANDING REVISION