* Front Page * Table of Contents * Return to Town

How to use nano

Nano is a simple to use text editor.

Start it by typing nano on the command line, optionally followed by the name of a file to edit.

$ nano ~/public_html/index.html

Nano's editing commands are listed at the bottom of the screen. When you see a ^ character, it indicates the Ctrl key. So, for example, ^O Write Out means press Ctrl-O to save your work, and ^X Exit means press Ctrl-X to exit. Pretty straight forward!

Configuration

$ cp /etc/nanorc ~/.config/nano/nanorc

That command will copy the sample configuration file in your home directory. Now you can edit ~/.config/nano/nanorc to customize nano.

$ nano ~/.config/nano/nanorc

You can check the nanorc manpage for more information about certain options.

Newer manpage for nano 4

Notable options

Changing editor colors

Valid names for the foreground and background colors are: white, black, blue, green, red, cyan, yellow, magenta, and normal -- where normal means the default foreground or background color. The name of the foreground color may be prefixed with bright. And either "fgcolor" or ",bgcolor" may be left out.

Simpler keybindings

If you are used to common keybindings in graphical editors, append this to your nanorc:

bind ^Q exit all bind ^S savefile all bind ^F whereis all bind ^C cancel all bind ^Z undo all bind ^Y redo all bind M-U undo all bind M-Y redo all bind ^X cut all

If you're using a nano version higher or equal to 3.2, you can also add this after the other keybindings:

bind ^C copy main bind ^V paste all

Enabling Spellcheck

Tilde.town has the aspell spell checker installed. To configure it for use with nano add the following line to your nanorc:

set speller "aspell -x -c"

If you want to use a different dictionary, use the -l option, e.g.

set speller "aspell -l en_GB -x -c"

For a list of currently installed dictionaries, run the following from your command line

$ aspell dicts


last compiled: 2024-10-15 11:00:58.792855