NANO Terminal Text Editor
nano [options] [[+line[,column]] file]...nano [options] [[+[crCR](/|?)string] file]...Introduction
Section titled “Introduction”nano stands for Nano’s ANOther editor. Quite weird, isn’t it?
If you have nothing but a Terminal window attached to a remote machine, nano is your best friend to edit any types of files.
Moreover, if you want to learn how to customize nano in depth, I suggest you to read nanorc config file article.
Another famous terminal-based text editor is vim, which is a lot more complex than nano.
Options
Section titled “Options”The most useful options are:
−B,−−backup: When saving a file, back up the previous version of it, using the current filename suffixed with a tilde (~)−J NUM,−−guidestripe=NUM: Draw a vertical stripe at the given column (help judge the width of the text). The color of the stripe can be changed with set stripecolor innanorcfile.−Q "regex",−−quotestr="regex": Set the regular expression for matching the quoting part of a line. It’s possible to rejustify blocks of quoted text when composing email, and to rewrap blocks of line comments when writing source code.−T NUM,−−tabsize=NUM: Set the width of a tab toNUMcolumns. The value of number must be greater than0(default is8).−Y NAME,−−syntax=NAME: Specify the name of the syntax highlighting to use. It’s chosen among the ones defined in thenanorcfiles.−i,−−autoindent: Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragraph).−l,−−linenumbers: Display line numbers to the left of the text area. (Any line with an anchor additionally gets a mark in the margin.)−m,−−mouse: Enable mouse support, if available for your system. When enabled, mouse clicks can be used to place the cursor, set the mark (with a double click), and execute shortcuts. The mouse will work in the X Window System, and on the console whengpmis running. Text can still be selected through dragging by holding down theShiftkey.−t,−−saveonexit: Save a changed buffer without prompting (when exiting with^X).
Examples
Section titled “Examples”The cursor can be put on the first or last occurrence of a specific string by specifying that string after +/ or +? before the filename.
The string can be made case-sensitive and/or caused to be interpreted as a regular expression by inserting c and/or r after the + sign.
These search modes can be explicitly disabled by using the uppercase variant of those letters: C and/or R.
When the string contains spaces, it needs to be enclosed in quotes.
Given a file called my-file.txt with the following content:
Hello JeyFooterGood luckWell doneFooterTo open this file at the first occurrence of the word “Footer”, you would type:
nano +c/Footer my-file.txtTo open this file at the last occurrence of the word “Footer”, you would type:
nano +c?Footer my-file.txtWhen you have finished editing a file, press Ctrl + X to exit and Y to save (or N to discard) changes.
Moreover, if instead of a filename you provide a dash (-), nano will read data from standard input.
nano -Reading data from keyboard; type ^D or ^D^D to finish.Quotes
Section titled “Quotes”Here are some useful links I used while writing this article: