diff --git a/src/text.c b/src/text.c
index 2e99cc64309e0595613250d1272596c5593f3069..00b554a21fc24a44e99df0bf0f73f89cf4c1c02a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -764,6 +764,8 @@ void do_enter()
     assert(openfile->current != NULL && openfile->current->data != NULL);
 
 #ifndef NANO_TINY
+    add_undo(ENTER);
+
     /* Do auto-indenting, like the neolithic Turbo Pascal editor. */
     if (ISSET(AUTOINDENT)) {
 	/* If we are breaking the line in the indentation, the new
@@ -806,6 +808,10 @@ void do_enter()
 
     openfile->placewewant = xplustabs();
 
+#ifndef NANO_TINY
+    update_undo(ENTER);
+#endif
+
     edit_refresh_needed = TRUE;
 }