Using the Nano Text Editor

Back to Home Page


What is Nano?

Nano is a simple text editor that works directly in your command line or terminal. It's one of the easiest command-line editors to learn and use, making it perfect for beginners.


Opening Nano

To open Nano and create a new file or edit an existing one:

nano filename.py

Replace "filename.py" with the name of your file. If the file doesn't exist yet, Nano will create it when you save.

You can also open Nano without specifying a file:

nano

This opens a blank document that you can save later.


Understanding the Nano Interface

Nano Editor Interface

Note: If you don't see this image, don't worry! The image isn't necessary to learn Nano.

The Nano interface has three main parts:

  1. Title bar (top): Shows the version of Nano, the current filename, and whether the file has been modified
  2. Edit area (middle): This is where you type and edit your text
  3. Shortcut menu (bottom two lines): Shows the most common keyboard commands

In the shortcut menu, the "^" symbol means the Ctrl key. For example, "^X" means "press Ctrl and X together".


Basic Navigation

Moving around in Nano is simple:


Essential Commands

Here are the most important commands you'll use in Nano:

File Operations

Editing

Other Useful Commands


Example: Creating a Python File with Nano

Let's create a simple Python program using Nano:

  1. Open Nano to create a new Python file:
    nano hello.py
  2. Type the following Python code:
    print("Hello, world!")
    name = input("What's your name? ")
    print(f"Nice to meet you, {name}!")
          
  3. Save the file by pressing Ctrl+O, then press Enter to confirm
  4. Exit Nano by pressing Ctrl+X
  5. Run your Python program:
    python hello.py

Tips for Using Nano


What's Next?

Now that you know how to use Nano, try:


Back to Home Page