diff --git a/ChangeLog b/ChangeLog
index cf0ff8b967ac78ae04d8cd5abf89361181bc11bf..8d674cdc7b37446bab8976ff0e32b6f02eeba00a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-22  Chris Allegretta <chrisa@asty.org>
+	* Add ability to kill the trailing spaces when justifying
+	code.  New nanorc option kill_spaces_on_wrap, we'll see
+	whether this warrants a command line flahg or not.
+
 2016-02-22  Benno Schulenberg  <bensberg@justemail.net>
 	* src/nano.c (free_openfilestruct): Elide this function.
 	* scr/global.c (thanks_for_all_the_fish, free_list_item): Condense.
diff --git a/src/nano.h b/src/nano.h
index 28f1b85ba650fa158fa8b2768e5a3662a4fb53df..987ebd2f480b2169986d8824e50fa89ceb168105 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -517,7 +517,8 @@ enum
     POS_HISTORY,
     LOCKING,
     NOREAD_MODE,
-    MAKE_IT_UNIX
+    MAKE_IT_UNIX,
+    KILL_TRAILING_SPACES
 };
 
 /* Flags for the menus in which a given function should be present. */
diff --git a/src/rcfile.c b/src/rcfile.c
index 785cd901177cabe843f179e215b5344cb885bd6d..6b20b9bc50331389c37f67a8e19d285c5b85d247 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -90,6 +90,7 @@ static const rcoption rcopts[] = {
     {"backwards", BACKWARDS_SEARCH},
     {"casesensitive", CASE_SENSITIVE},
     {"cut", CUT_TO_END},
+    {"kill_spaces_on_wrap", KILL_TRAILING_SPACES},
     {"locking", LOCKING},
     {"matchbrackets", 0},
     {"noconvert", NO_CONVERT},
diff --git a/src/text.c b/src/text.c
index 996479b8fcd70fea3108f01465811253adb6ca41..f16996d606bdcd0ab06c108000369c0c66af66cb 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1277,7 +1277,7 @@ bool do_wrap(filestruct *line)
 
 	/* If after_break doesn't end in a blank, make sure it ends in a
 	 * space. */
-	if (!is_blank_mbchar(end)) {
+	if (!is_blank_mbchar(end) && !ISSET(KILL_TRAILING_SPACES)) {
 #ifndef NANO_TINY
 	    add_undo(ADD);
 #endif
@@ -2174,7 +2174,10 @@ void do_justify(bool full_justify)
 #endif
 
 	    /* Break the current line. */
-	    null_at(&openfile->current->data, break_pos);
+            if (ISSET(KILL_TRAILING_SPACES))
+		null_at(&openfile->current->data, break_pos - 1);
+	    else
+		null_at(&openfile->current->data, break_pos);
 
 	    /* Go to the next line. */
 	    par_len--;