diff --git a/doc/nano.1 b/doc/nano.1
index 96e9cdf0600d906ef046a03b47a0c70a9eac27be..ae0da16db002416ee9c490ef85e082db7d3b4c96 100644
--- a/doc/nano.1
+++ b/doc/nano.1
@@ -108,6 +108,10 @@ won't work properly with this option enabled.
 .BR \-L ", " \-\-nonewlines
 Don't add newlines to the ends of files.
 .TP
+.BR \-M ", " \-\-trimblanks
+Snip trailing whitespace from the wrapped line when automatic
+hard-wrapping occurs or when text is justified.
+.TP
 .BR \-N ", " \-\-noconvert
 Disable automatic conversion of files from DOS/Mac format.
 .TP
diff --git a/doc/nano.texi b/doc/nano.texi
index 8a44dfaf99a345008a94c97c5c89bebdc6887adf..ea4eb90cd90728c3ff12155b40aaf8e6fdc0476b 100644
--- a/doc/nano.texi
+++ b/doc/nano.texi
@@ -200,6 +200,11 @@ won't work properly with this option enabled.
 @itemx --nonewlines
 Don't add newlines to the ends of files.
 
+@item -M
+@itemx --trimblanks
+Snip trailing whitespace from the wrapped line when automatic
+hard-wrapping occurs or when text is justified.
+
 @item -N
 @itemx --noconvert
 Disable automatic conversion of files from DOS/Mac format.
diff --git a/src/nano.c b/src/nano.c
index a21625cf4cc45d77f602ed41a34a3512e553ffb3..e2bdf5d7e5df17b63ca06746ab7d0d3c91c2df63 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -818,6 +818,8 @@ void usage(void)
 		N_("Fix numeric keypad key confusion problem"));
 	print_opt("-L", "--nonewlines",
 		N_("Don't add newlines to the ends of files"));
+	print_opt("-M", "--trimblanks",
+		N_("Trim tail spaces when hard-wrapping"));
 #ifndef NANO_TINY
 	print_opt("-N", "--noconvert",
 		N_("Don't convert files from DOS/Mac format"));
@@ -2031,7 +2033,7 @@ int main(int argc, char **argv)
 
 	while ((optchr =
 		getopt_long(argc, argv,
-				"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
+				"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
 				long_options, NULL)) != -1) {
 		switch (optchr) {
 			case 'b':
@@ -2085,6 +2087,9 @@ int main(int argc, char **argv)
 			case 'L':
 				SET(NO_NEWLINES);
 				break;
+			case 'M':
+				SET(TRIM_BLANKS);
+				break;
 #ifndef NANO_TINY
 			case 'N':
 				SET(NO_CONVERT);