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!
$ 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.
set nowrap- disables text wrapping.
set linenumbers- enables line numbers. Their color can also be changed with
set numbercolor fg,bg(see section named 'Changing colors' below).
set zap- makes it possible to highlight text and then remove it with a backspace.
set tabsize 4- makes tabs smaller.
set mouse- enables mouse support.
set smooth- enables smooth scrolling.
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.
set titlecolor fg,bg- Sets colors for the title bar (nano version, file being edited, etc.).
set numbercolor fg,bg- Sets colors for the line numbers (line numbers have to be enabled manually).
set keycolor fg,bg- Sets colors for the shortcut key combos in the help lines at the bottom.
set functioncolor fg,bg- Sets colors for the function descriptions in the help lines at the bottom.
set errorcolor fg,bg- Sets colors for the status bar when an error is displayed.
set statuscolor fg,bg- Sets colors for the status bar (displayed with Ctrl+C with normal keybinds).
set selectedcolor fg,bg- Sets colors for selected text.
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
last compiled: 2021-06-04 12:34:03.178788