GNU nano is a small, user-friendly text editor that evolved from the Pico text editor created for Unix-like systems. It was added to the GNU Project shortly after its initial release. While Vim is a powerful text editor, it is not the most user-friendly, as evidenced by its multiple modes, bare interface, and many keystroke commands— some of which are unintuitive. The nano editor, on the other hand, is more visually helpful in that it displays its command shortcuts at the bottom of every open file. Likewise, nano has fewer commands than Vim, and most command keystrokes share Ctrl as a common prefix. It also does not have different modes that you need to switch between.

Despite these advantages, nano lacks many of the features that make Vim so powerful, like split-screen, text completion, syntax coloring, and more.

The GNU nano interface:

nano command cheat sheet

The nano Command

The nano command invokes the GNU nano editor. Without any arguments, the command will open a new file for editing, and you can later save this file with a specific name. Use the syntax nano {file name} to open an existing file. If the file does not exist, nano creates a file by the name specified and opens the file for editing. Like Vim, nano supports multiple files being opened simultaneously. These files are opened into different “buffers” that you can switch between.

nano Shortcuts

In GNU nano, the functions you use to work with text files and the editor itself are referred to as shortcuts. You activate most shortcuts by pressing the Ctrl key (represented as ^ in the editor) and then pressing the key that corresponds to the function you’re trying to perform.

The below table lists some of the common nano shortcuts.

Shortcut Used to
Ctrl+G Open nano to help screen
Ctrl+X Exit nano or close currrent buffer
Ctrl+O Save currently open file
Ctrl+J Justify current paragraph
Ctrl+R Insert another file into the current one
Ctrl+W Search the file
Ctrl+K Cut the currently selected line
Ctrl+U Paste the line that was cut
Ctrl+C Dsiplay the cursor positions

Navigation

Like other text editors, you can navigate in nano using the arrow keys, Page Up, Page Down, Home, etc. If you are missing these keys, nano also provides shortcuts for them, e.g., Ctrl+V to navigate to the next page and Ctrl+Y to navigate to the previous page.

Copying Text

Copying parts of the text on a line requires you to “mark” the text you want to copy with the Ctrl+^ shortcut. You then navigate your cursor to highlight the text you want to copy. Pressing Alt+^ copies the marked/highlighted text, and Ctrl+U pastes it.