Usage summary of common Editors under Linux
The following commonly used editors for Linux are nano, vi, vim
nano editor
The general Linux distribution has this editor, so this is more versatile, but the function is relatively simple, like windows txt. If the system does not come with it, you can use one of the following commands to install it:
Apt-get install-y nano or yum-y install nano
Usage method:
1. Open or New File Command: nano File Name
2. There is a command prompt below the interface after entering, just watch the prompt operation, but the prompt here is not complete, you need to see the detailed prompt can use Ctrl+G to view. Here's a reminder: the symbol ^ in the command represents the Ctrl key, the letters need not be capitalized, and the minus sign represents the Alt key.
3. Summary of Common Commands:
Search: ^ W, multiple searches can press once more to return directly
Cut line: ^K
Copy line: ^ 6
Paste: ^U
vi editor
Usually Linux also comes with this editor, like windows Wordpad. If the system is not available, it is not recommended to install vi. It is recommended to install vim directly, which has the same function as vi and supports multiple plug-ins.
vi has two modes: command mode (all keys are commands), edit mode (all keys are input).
Mode Interchange: Uppercase I key can be used to enter command mode and Esc key can be used to launch command mode.
The vi command helps analyze:
root:~# vi -h VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 07 2019 15:35:43) usage: vim [arguments] [file ..] edit specified file(s) or: vim [arguments] - read text from stdin or: vim [arguments] -t tag edit file where tag is defined or: vim [arguments] -q [errorfile] edit file with first error Arguments: -- Only file names after this -v Vi mode (like "vi") -e Ex mode (like "ex") -E Improved Ex mode -s Silent (batch) mode (only for "ex") -d Diff mode (like "vimdiff") image git It's useful to compare changes in multiple files that way. -y Easy mode (like "evim", modeless) -R Readonly mode (like "view") This prevents mistakenly altering files -Z Restricted mode (like "rvim") -m Modifications (writing files) not allowed -M Modifications in text not allowed -b Binary mode binary mode -l Lisp mode -C Compatible with Vi: 'compatible' -N Not fully Vi compatible: 'nocompatible' -V[N][fname] Be verbose [level N] [log messages to fname] -D Debugging mode -n No swap file, use memory only -r List swap files and exit -r (with file name) Recover crashed session -L Same as -r -A start in Arabic mode -H Start in Hebrew mode -F Start in Farsi mode -T <terminal> Set terminal type to <terminal> --not-a-term Skip warning for input/output not being a terminal -u <vimrc> Use <vimrc> instead of any .vimrc --noplugin Don't load plugin scripts -p[N] Open N tab pages (default: one for each file) -o[N] Open N windows (default: one for each file) -O[N] Like -o but split vertically + Start at end of file +<lnum> Start at line <lnum> --cmd <command> Execute <command> before loading any vimrc file -c <command> Execute <command> after loading the first file -S <session> Source file <session> after loading the first file -s <scriptin> Read Normal mode commands from file <scriptin> -w <scriptout> Append all typed commands to file <scriptout> -W <scriptout> Write all typed commands to file <scriptout> -x Edit encrypted files --startuptime <file> Write startup timing messages to <file> -i <viminfo> Use <viminfo> instead of .viminfo -h or --help Print Help (this message) and exit --version Print version information and exit
Common commands (command mode):
Location correlation Status: Ctrl+G view current location Cursor movement: gg prefix, G prefix, ^prefix, $prefix, w prefix, w prefix, e prefix, e prefix, E prefix, {{prefix,}} the next prefix, [[last function,]] the next function Turn over: zz cursor return, Ctrl+F next page, Ctrl+B upper page, Ctrl+Y downlink, Ctrl+E upstream Find: / Find text (next match in n, last match in N) Editing related Undo operation:u Redo operation: Ctrl+r Copy line: yy Cut line: dd Paste line:p Enter editing mode: a,o,i,A,O,I Delete Characters: d+ (Number) Direction, Replacement: r+ (number) letters to be replaced; global substitution:% s / matched text / text to be replaced / g Selection correlation Selecting mode V, you can use o to switch the cursor position, select text to copy y, delete d, replace r, and so on. Selection mode Ctrl+V, you can use o to switch the first cursor position, mainly used for text editing by line, press I into the editing position, press Esc application and all lines. This function is very useful for annotating code.