Character terminal text editor
nano is a character terminal text editor, a bit like the editor program under DOS. It is much simpler than vi/vim and is more suitable for Linux beginners. The default editor for some Linux distributions is nano.
The nano command can open the specified file for editing. By default, it will automatically break lines, that is, automatically split into several lines when inputting too long content in one line. However, processing some files in this way may cause problems. For example, in the configuration file of the Linux system, automatic line breaking will cause the content that can only be written on one line to be broken into multiple lines, which may cause the system to malfunction. Therefore, if you want to avoid this situation, add the -w
option.
nano [options] [[+row,column] filename]...
-h, -? --help display this information
+row,columnStart from the indicated column number and row number
-A --smarthome Enable smart HOME key
-B --backup Save backup of existing files
-C <directory> --backupdir=<directory> Directory to store unique backup files
-D --boldtext Use bold instead of color inversion
-E --tabstospaces Convert entered tab characters to whitespace
-F --multibuffer enables multiple file buffer functions
-H --historylog records and reads search/replacement history strings
-I --ignorercfiles Do not refer to nanorc files
-K --rebindkeypad fixes numeric keypad key confusion problem
-L --nonewlines Do not add newlines to the end of the file
-N --noconvert Do not convert from DOS/Mac format
-O --morespace Use one more line when editing
-Q <string> --quotestr=<string> Quote represents string
-R --restricted restricted mode
-S --smooth scroll by line instead of half screen
-T <#number of columns> --tabsize=<#number of columns> Set tab width to #number of columns
-U --quickblank status line flashes quickly
-V --version Display version information and exit
-W --wordbounds detect word boundaries more accurately
-Y <string> --syntax=<string> syntax definition for highlighting
-c --const Continuously display cursor position
-d --rebinddelete Fix backspace/delete key confusion problem
-i --autoindent automatically indent new lines
-k --cut cuts from cursor to end of line
-l --nofollow Do not follow symbolic links, but overwrite
-m --mouse enable mouse function
-o <directory> --operatingdir=<directory> Set the operating directory
-p --preserve Preserve XON (^Q) and XOFF (^S) keys
-q --quiet silently ignore startup problems, such as rc file errors
-r <#number of columns> --fill=<#number of columns> Set the wrap width to #number of columns
-s <program> --speller=<program> Enable alternative spell checker
-t --tempfile Automatically save when leaving, do not prompt
-u --undo Allow universal undo [Experimental feature]
-v --view view (read-only) mode
-w --nowrap do not wrap automatically
-x --nohelp Do not show the auxiliary area
-z --suspend enable suspend function
-$ --softwrap enable soft newlines
-a, -b, -e,
-f, -g, -j (ignored for compatibility with pico)
Cursor Control
Copy, Cut and Paste
Paste: Ctrl+U
If you need to copy/cut multiple lines or part of a line, first move the cursor to the beginning of the text to be copied/cut, press Ctrl+6 (or Alt+A) to mark it, and then move the cursor to the text to be copied/cut. end. At this time, the selected text will be highlighted. Use Alt+6 to copy and Ctrl+K to cut and paste. If you want to cancel while selecting text, just press Ctrl+6 again.
search
Press Ctrl+W, then enter the keyword you want to search for, and press Enter to confirm. This will navigate to the first matching text, and you can then use Alt+W to navigate to the next matching text.
turn page
Save
Use Ctrl+O to save changes
quit
Press Ctrl+X
If you modify the file, you will be asked if you want to save the changes. Enter Y to confirm saving, enter N not to save, and press Ctrl+C to cancel and return. If you entered Y, the next step will ask you to enter the file name you want to save. If you do not need to modify the file name, just press Enter; if you want to save it under another name (that is, save as), enter the new name and confirm. At this time, you can also use Ctrl+C to cancel the return.