Linux 6-use vi and vim
I. Three Modes of vi and switching between them 1. normal Mode 1) move the cursor by pressing the arrow keys, Page Up, Page Down, Home, End, and other buttons to move the cursor G to the last row of the file: 1G, gg, move n <space> to the first line of the file, right shift n places n <enter>, and move down n rows 2) Search/word search down? Word search n forward to next N reverse next 3) Replace note that there cannot be spaces between the following commands: n1, replace word1 between n2s/word1/word2/g n1 and n2 with word2: 1, replace word1 between the first and last lines of $ s/word1/word2/g with word2: 1, $ s/word1/word2/gc replace word1 between the first line and the last line with word2, and prompt the user to confirm 4) Delete x, X, delete key delete nx delete n consecutive characters dd delete the entire line ndd delete n rows d1G delete to the first line dG delete to the last line d $ delete to the end of the line d0 delete to the first line 5) copy the y1G row of yy to copy the y1G row of n rows to the yG row of the first row to copy the y $ row to the end of the y0 row to copy the first 6 rows) paste p to the next line and paste P to the last line. 7) u restores the previous action. 8) ctrl + r redo the previous action. 9 ). repeated action 2. in general mode, press I, I, o, O, a, A, r, and R to enter edit mode. In general mode, Press Esc to exit edit mode. 3. in command column command mode, enter 『:/? "Any of the three buttons enters the command mode. Press Esc to exit the command mode and enter the General mode. Common commands: w write: w! When the file is read-only, it is mandatory. If it cannot be written, it depends on your permission for the file. q: q! Forced exit, not archive: wq storage Exit: w filename another storage: r filename read into another document: set nu display row number: set nonu do not show row number 2. vim features and application 1. color Display 2. select the v character for the block, and the position where the cursor passes is reversed! If you select row V, the rows with the cursor passed are reversed! [Ctrl] + v block selection. You can use a rectangle to select materials. y. Copy the reversed area. d. Delete the reversed area. 3. multi-file Editing: n editing next file: N editing previous file: files listing all files currently enabled by vim 4. multi-Window Editing: sp [filename] opens a new window. If filename is added, a new file is opened in the new window; otherwise, the two windows are the same file content (synchronously displayed ). [Ctrl] + w + ← the cursor can be moved to the lower window. [Ctrl] + w + ← the cursor can be moved to the upper window. 3. We recommend that you set up the vim configuration through ~ /. Vimrc to configure the vim operating environment, such as vim ~ /. Vimrc "Double quotation marks for this file (") note: set hlsearch "High Brightness anti-whitelist set backspace = 2" you can use the backspace key to delete set autoindent "auto-scale down set rdent" to display the status of the last row in the lower left corner of set showmode. status set nu "displays the row number at the beginning of each row! Set bg = dark "show different background colors syntax on" syntax test, color display.