Text editors are software specifically designed to keep the interests of programmers in mind. They are environments with features specializing in navigating, editing, and formatting text.
Although Linux has seen an increase in the options of available text editors, it certainly doesn’t lack when it comes to the available default options. A popular example of a text editor that comes integrated with Linux is the Nano Text Editor.
Nano has a lot of features. Being integrated with Linux, it’s the go-to option for most people to edit .txt files.
A useful feature of the nano text editor is the option to undo and redo changes.
If you’re someone struggling to learn how to undo changes in the Nano Editor, then this guide is meant for you. Join us as we take a look at the different methods to undo changes in Nano Editor.
With that said, let’s dive right in!
The Nano Text Editor
Before we begin, it’s a good idea to familiarize ourselves with the Nano Text Editor.
Nano can be seen as one of the more old-school editors. However, its integration with Linux makes it useful, allowing it to compete with the latest editors in this day and age.
Nano supports GNU Autoconf, search-and-replace, automatic indentations, and spell checking. These features make nano easy to understand and use. The shortcut keys are available at the bottom of the text editor. This saves one from the hassle of trying to memorize them.
You can check the version of the Nano Editor by typing the following in the Command Terminal:
The output should look similar to the one in the image below.
If the editor is not installed in your system, type the following in the Command Terminal.
For Ubuntu and Debian based distributions,
For CentOS-based distributions,
Using The Nano Text Editor
The Nano Editor is simple and easy to use. To use the Nano Editor, follow the steps given below.
It should be noted that we’re going to be using Ubuntu 20.04 LTS for the sake of this tutorial
It’s best to create a text file before using the Nano Editor. For this purpose, type the following in the Command Terminal to create a text file.
$ cat <file name>.txt
In our case,
$ cat nanoTest
Once that’s done, add a bunch of lines to your file. Once you’re finished, press Ctrl + D on your keyboard to stop writing text.
By using the $cat command again, you should be able to see the contents of the data.
You can now type the following to open the file in the Nano Editor:
Once that is done, You should see the file open in the Nano Editor.
With this, you are ready to learn how to undo changes in Nano Editor
Undo Changes In Nano Editor [Keystroke Method]
This method of making changes in the Editor is simple and uses keyboard shortcuts. Just follow the steps to ensure that you can undo changes without facing any problems.
Start by opening the text file of your choice in the nano editor, or create a new one using the $ nano command as follow:
This should open the preferable file of your choice.
The next step is to undo the changes. For this purpose, we’ll edit the file’s contents to make it look different from the previous one. To undo these changes, simply press Alt + U on your keyboard.
In case the previous method doesn’t work, use the following command to open the file of your choice,
The -u option should provide you with the necessary permissions to edit the file.
If you’re not a big fan of writing options, again and again, you can make an alias for the option. To achieve this, type the following in the Command Terminal:
This should make nano an alias for nano -u, meaning every time you type nano in the Command Terminal from now on, it’ll serve as a replacement for nano -u.
Aside from undoing changes, you can also redo the changes you’ve undone in the Nano Editor. To Redo the changes, just press Ali + E on your keyboard.
If you’ve followed the steps correctly, you should now have a decent idea of how to undo changes in the Nano Editor.
Additional Shortcuts For Nano
The Nano Editor isn’t limited to just undoing and redoing text on the press of a keystroke; rather, it has a lot of additional features, most of which are also integrated via shortcuts on the keyboard.
Here is a list of additional keystrokes for the editor.
Ctrl + X Saves and exits the text editor.
Ctrl + G Shows a list of all available commands
Ctrl + _ Moves the cursor to a specific line
Ctrl + k Cut the selected text.
Alt + 6 Copy the selected text to the clipboard
Ctrl + u Used to paste the most recent text from clipboard.
Conclusion
We hope this guide helped you learn about undoing changes in the Nano Editor. We covered some basic information about the Nano editor, along with the steps to install it. We then covered the basics about using it and then talked about how to undo changes in the editor.
With this, we hope that you’re more comfortable with using this gem of a text editor and wish you all the best on your Linux journey.