How to Undo Changes in “nano” Text Editor in Ubuntu

Nano has experimental undo/redo feature. As you’ll see from the nano manual (type “man nano” in a Terminal to read that), you’ll need to start nano with the -u option

 $ nano -u somefile.txt

… and then you can use Alt-U to undo and Alt-E to redo.

It’s little bit frustrating that you have to type the “-u” option every time when you want to edit a file, but hopefully there is a solution and its name is “alias”.

Aliases are a way for you to customize the commands by giving them aliases (nicknames). You can use them to remember commands with a lot of options or make their names shorter and easier to type. To setup aliases, all you need is to open the ~/.bash_aliases file and type in:

alias nano='nano -u'

If you want to add more aliases, enter each of them on separate line.

Now, typing “nano” is equal as typing “nano -u”. Tricky, yeah?

 

One thought on “How to Undo Changes in “nano” Text Editor in Ubuntu

  1. Delyan Angelov

    Using nano in the console, puts a very low ceiling on your editing power/efficiency.

    Join the dark side, and try vim, or even better – emacs 🙂 for a day or two … the learning curve may be steeper, but you will not regret it.

    P.s. … we have cookies 😀

Comments are closed.