Sometimes, you might need to edit a file on your Raspberry Pi: perhaps to edit the /etc/network/interfaces
file in order to reconfigure your Raspberry Pi network interfaces, or you might need a text editor to write a document.
Fortunately, there are several text editors installed with Raspbian. The most commonly used text editors are:
Originally created in 1999 by Chris Allegretta, nano is the easiest text editor to use included on the Raspberry Pi.
To edit a file in nano, you simply need to start typing. Once you have made changes, you need to save them and exit. The commands that you see at the bottom of the screen can be accessed by pressing the Ctrl key on your keyboard followed by the letter.
nano
command as shown in the following screenshot:The other text editor installed on your Raspberry Pi is the vi text editor. The vi editor was originally created for Unix-based operating systems by Bill Joy in 1976.
The name vi is derived from the shortened abbreviation of the word visual. The vi editor is one of the most widely used text editors in Linux.
The vim (improved vi) editor is a bit more complicated to use than nano. The vi editor is designed to stay out of your way, and as such, you won't see any menus or unnecessary information on the screen.
The vim editor has several different modes that you use to operate it. One of the modes is insert mode. When you are in insert mode, you can use vi like you would use the nano text editor, but here you simply type the text and use the arrow keys to navigate the file. To get into insert mode, press the Insert key or type a capital I.
In order to save the file, we need to enter in the command mode. To do this, press the Esc key followed by the : key. This will bring up a command prompt at the bottom of the vim window.
There are many different commands available in vim, as follows:
Command |
Description |
---|---|
| |
| |
| |
|
These commands can be entered in Command Prompt, or when you are navigating the text and are not in insert mode.
An example of these commands is the wq
command. This command saves and quits vim when you press Enter. You won't be asked whether you want to save your changes, as vim knows what you want, based on the command you give!
If you don't want to save your changes, simply enter the q!
command.
There are many other text editors that can be installed onto your Raspberry Pi, such as geany.