A text editor is a software that edits text. They are often used in making system configuration files and program sketches. There are two kinds of text editors you can use on a Raspberry Pi: desktop graphical editors and command-line editors.
Desktop Graphical Editors
Desktop graphical editors are text editors that have a GUI (Graphical User Interface). These are the text editors you’re probably aware of. They are the ones you see on the start menu, but they can be accessed via terminal as well. More importantly, the main difference between graphical editors and the following kind is that they require both mouse and keyboard to operate properly.
Some of the desktop graphical editors that you can use on a Raspberry Pi are:
- Text Editor
Command-line editors, as you may have guessed, can only be accessed via the command line. These make them more convenient for embedded applications. Because unlike desktop graphical editors, command-line editors can be used with only a keyboard. As an alternative to the point-and-click interface of graphical editors, command-line editors use keyboard shortcuts.
Some of the command-line editors you can use on a Raspberry Pi are:
In this tutorial, we are going to explore Mu and Nano as a quick demonstration of graphical editors and command-line editors.
Mu is a text editor, and an IDE (Integrated Development Environment) especially made for Python programming. It is known for being easy-to-use as its target users are beginner users, just like the Raspberry Pi.
Before you install Mu, make sure your Raspberry Pi OS is up to date by entering
sudo apt-get update and
sudo apt-get dis-upgrade in the command line. There are two ways you can install Mu in your system. The first one is by accessing the Menu on the top left side of your desktop.
Under the Menu, go to Preferences, then choose Recommended Software.
A list will pop up that displays all recommended software for the Raspberry Pi. If you don’t see Mu, just enter Mu on the search bar on the bottom right of the window.
Click install (I already have Mu so an install button didn’t appear on Figure 2).
After installation, you can start Mu by going to Menu > Programming > Mu.
You can also get Mu by using the CLI (Command Line Interface). On your desktop, start the terminal by clicking the blackboard icon in the quick launch toolbar. Alternatively, you can open it by pressing CTRL + ALT + T.
In the terminal, enter
sudo pip3 install mu-editor to install mu.
You can start Mu by simply entering
The current version of Mu offers four modes. You can change them depending on what you intend to use Mu for. For now, we are going to use it for Python programming.
Select the Python 3 mode and click OK.
Writing Code in Mu
Let us now write our first program. Copy the line below and save your file. No need to add .py on the file name as Mu already assumes the file type when you set the mode to Python 3.
Press Run to execute the program. The output will be visible on an integrated Python shell below the text editor.
To stop the program, click Stop.
Useful Mu Features
One useful feature of Mu is error highlighting. Mu checks for errors and highlights them in red so you can detect coding mistakes without any problem.
Additionally, you can click Check to search for errors on your code without running the program.
GNU Nano is the native text editor of most Linux distros. It’s easy to use and offers a myriad of keyboard shortcuts, which are useful when writing in a computer’s CLI (Command Line Interface).
Nano comes with the Raspberry Pi OS as default, and you can start it by simply entering
The best thing about Nano is that it is very convenient. You type text directly, and the keyboard shortcuts are always visible. The carets on the shortcuts stand for the CTRL button. So, for example, if you need help, just press CTRL + G. Same goes with the other shortcuts. If you want to cut a selected text, simply type CTRL + K.
Furthermore, a new and unnamed file will display a new buffer on the title bar. After changing the text, the title bar will display Modified at the top right side.
I wrote a sample text for demonstration and saved it using the shortcut CTRL+O.
Sign Up & Get at Least Two $5 Coupons Now: https://jlcpcb.com/quote