Nano Text Editor Shortcuts

GNU nano home page.

Nano is the standard editor in Ubuntu; installation is not required as it is included by default.

In nano, there are two types of control sequences: Control+letter and Meta+letter. The former (partially duplicated by functional keys F1-F12) are used for text editing and file operations. Meta-sequences are designed to change editor settings (the same result can be achieved via command-line options).

How to enable syntax highlighting in Nano
Nano also provides an external configuration tool — the user config ~/.nanorc. By performing certain manipulations in it, you can slightly extend the editor’s functionality, in particular, ensure syntax highlighting. To enable highlighting based on the type of file being viewed, you need to uncomment the lines in the global configuration file /etc/nanorc and add them to the user configuration file ~/.nanorc.

Recall that on a PC keyboard, the role of the Meta key is usually performed by pressing the Alt key (in some layouts specifically the right Alt, or conversely, the left one), or by pressing and releasing the Escape key.

Basic editor control: Ctrl+X — exit, Ctrl+O — save, Ctrl+W — search, arrows — cursor movement.

Control sequences are as follows (in brackets — duplicating functional keys and, sometimes, Meta-sequences):

Control+G (F1) - call the full help menu;
* Control+X (F2) - exit the program;
* Control+O (F3) - write the current file;
* Control+R (F5) - insert a file into the current one;
* Control+W (F6) - search for text in the current file;
* Control+\ (F14 or Meta+R) - replace text in the current file;
* Control+Y (F7 or PgUp) - move to the previous screen;
* Control+V (F8 or PgDwn) - move to the next screen;
* Control+K (F9) - cut the line at the cursor position, saving it in the buffer (cutbuffer);
* Control+U (F10) - paste the contents of the cutbuffer into the line at the cursor position; if the latter has not changed, it acts as Undo, which is not provided by default;
* Control+C (F11) - display information about the cursor position in a form like:

  [ line 4 of 81 (4%), character 117 of 3092 (3%) ]

* Control+T (F12) - spell check (via an installed spelling program, e.g., ispell);
* Control+P - move the cursor up one line;
* Control+N - move the cursor down one line;
* Control+F - move the cursor one character forward;
* Control+B - move the cursor one character backward;
* Control+A - move the cursor to the beginning of the current line;
* Control+E - move the cursor to the end of the current line;
* Control+L - redraw the current screen;
* Control+^ (Meta+A) - select (and place in the buffer) text starting from the current cursor position;
* Control+D - delete the character at the cursor position;
* Control+H - delete the character to the left of the cursor;
* Control+I - insert a tab character;
* Control+J (F4) - justify the current paragraph;
* Control+M - insert a carriage return (CR) at the cursor position;
* Control+_ (F13 or Meta+G) - go to a specified line number.

Meta-sequences usually work as toggles. They perform the following actions:

* Meta+C - enable/disable constant cursor position display;
* Meta+I - enable/disable auto-indentation;
* Meta+Z - enable/disable suspension;
* Meta+X - enable/disable help mode display;
* Meta+P - enable/disable pico editor emulation mode;
* Meta+W - enable/disable word wrap mode;
* Meta+M - enable/disable mouse support (only if built with gpm support);
* Meta+K - allow/disallow cutting to the end of the line;
* Meta+E - enable/disable the use of regular expressions (regexp).

Comparison with other editors

When choosing an editor for the terminal, users most often compare Nano, Vim, and Micro. Each solves its own tasks:

  • Vim (or Vi) — the de facto standard for system administrators. It possesses immense power but has a very high entry barrier due to its “modality” (the need to switch between insert mode and command mode).
  • Micro — a modern editor written in Go. Its main feature is that it behaves like familiar text editors from Windows or macOS: standard key combinations work (Ctrl+C, Ctrl+V, Ctrl+S), there is excellent mouse support, and even split-view out of the box. However, it often has to be installed manually.
  • Nano — the middle ground. It is simpler and more intuitive than Vim, and unlike Micro, it is almost guaranteed to be pre-installed in any Linux distribution, whether it’s a server Ubuntu or a minimalist Docker container.
FeatureGNU NanoVim (Vi)Micro
ComplexityVery simpleDifficult (requires learning)Very simple
KeysCtrl/AltSpecial commandsStandard (like Windows)
AvailabilityEverywhere by defaultEverywhere by defaultMust be installed
Best forQuick config editsProfessional codingComfortable console work

Why choose Nano?

Despite the presence of powerful competitors, Nano remains the most popular choice for everyday tasks for several reasons:

1. It is always at hand.
You don’t need to check if the editor is installed. In 99% of cases when you connect to a new server via SSH, Nano is already there.

2. Visual hints.
You don’t need to keep a list of commands in your head. At the bottom of the screen, there is always a “cheat sheet” that reminds you how to exit or save a file. This saves time and nerves in critical situations.

3. No traps.
Beginners often get stuck in Vim, not knowing how to exit (the famous :q!). In Nano, there is no such problem — management is transparent and predictable.

4. Speed.
To fix a single line in /etc/nginx/nginx.conf, Nano is the fastest tool. Open, change, save, close. The whole process takes seconds.

5. Safety when copying.
Unlike more complex editors, Nano correctly handles pasting text from the OS clipboard without trying to interpret characters as commands, which often happens in Vim without the special set paste mode.

Rork

Linux hobbyist into networking and digital privacy. I use this hub to translate and store technical notes on sysadmin tasks and anonymity tools. Tech should work for people, not the other way around.

Rate author
Add a comment