Command-line text editors

From time to time, there might be a need to make minor changes to code files or change configuration files from the command line. It is impractical to use a graphical text editor every time. There are command-line text editors that can come handy with some practice.

One useful text editor that comes with the Raspbian OS is nano. nano is a very simple text editor, and it is very easy to use. For example, let's consider a scenario where we would like to add a secret key for an API in your code file. This could be accomplished by opening the file via the Command Prompt (SSH or the command-line terminal from the desktop):

    nano visual_aid.py

It should open the contents of the file, as shown in the following screenshot:

nano text editor
  1. Navigate to the line that needs editing using the keyboard's arrow keys. The line could be edited manually, or the secret key could be pasted into the file (CMD V on Mac, Ctrl Shift V on Ubuntu Terminal and simply right-click on PuTTY).
  2. Once the file editing is complete, press Ctrl X to finish editing and Press Y to save the changes:
Save changes
  1. Press Enter at the next prompt to save the contents to the file.
Save contents to the original file

Learning to use command-line text editors can come handy while working on projects.

There are other text editors such as vi and vim. However, nano text editor is much simpler to use.