There are times when you want to revert the most recent action you took in the nano text editor such as you pasted a text which was not supposed to be in that file.
In that case, you can undo that action and get back to the previous state of your file.
Here's what you need to follow to undo and redo in the nano text editor:
|Action||For Linux||For macOS|
Want a more detailed explanation? Here you have it.
How to undo in the nano text editor
While using a Linux desktop, users generally use
Ctrl + Z to undo the most recent change but when you use the same shortcut in the nano, it will suspend the nano and will get you to the terminal prompt.
To undo the last action in the nano text editor, you press the
Alt + U shortcut and if you're on macOS, then you'll have to use
Option + U.
In the above example, I wrote a line that was not supposed to be there so I used the
Alt + U to undo my previous action.
Did you notice that it notified the undo action saying
Pretty cool. Right?
How to redo in the nano text editor
For those who don't know redo is nothing but completely opposite of undo as it lets you revert the effect of undo.
Let's suppose you pressed
Alt + U to undo the changes but then you realize "Oh, I shouldn't have done that in the first place".
In simple terms when you undo your action and realize that doing undo was the mistake itself there comes the role of redo.
It lets you revert the effect of undo.
To redo in the nano text editor, you press
Alt + E and if you are on macOS, then you press
Option + E.
As you can see when you redo it in the nano text editor, it will notify the action saying
In the above example, first I used the undo to remove the text and then pressed
Alt + E to redo the action.
Here's how to edit files in the nano text editor
Just getting started with the Nano text editor and have no idea how you can edit files using it. Well, we made a detailed guide to cater to this issue:
Have any doubts related to nano? leave a comment.