- The movement of the cursor
The command cursor moves h or^H Move one character to the left J or^j or ^N Move down one line K or^p Move up one line L or space to the right move a character G move to the last line of the file NG Move to row N of the file W moves to the beginning of the next word W moves to the beginning of the next word, ignoring punctuation B moves to the beginning of the previous word B moves to the beginning of the previous word, ignoring the punctuation L moves to the last line of the screen M moves to the middle line of the screen H Move to the first line of the screen e moves to the end of the next word, E moves to the end of the next word, ignoring punctuation ( Move to the beginning of a sentence move to the end of the sentence {move to the beginning of the paragraph} to the beginning of the next paragraph 0 or|move to the first column of the current row n|move to nth column of the current row^move to the first non-null character of the current line moves to the last character of the current line+or return moves to the first character of the next line-Move to the first non-empty character of the previous line
- Add text in VI
Command Insert action A after the cursor insert text A in the current line Insert text I insert text before the cursor i insert text before the current line O insert a new row below the current line o insert a new row at the top of the current line: R The file reads in the files ' contents and inserts them into the current line: NR file reads into the files ' contents, and inserts the nth row after escapeChar
- delete text in VI
command delete action x Delete the character at the cursor, plus the number of characters you want to delete in front of x NX removes n words from the current cursor Character X to delete the characters before the cursor, you can add the number of characters you want to delete before X. NX deletes the n characters from the current cursor. DW Delete to Next The beginning of a word NDW delete n characters from the current cursor DG delete line until end of file dd delete entire row ndd Delete db from current line delete the word NDB before the cursor deletes the n word from the current line: N,MD Delete n rows from the beginning of line D or d$ from the cursor to the end of the line Dcursor_command Delete to the cursor command, such as DG will be removed from when the production line to the end of the file ^h or backspace is inserted, delete the preceding character ^w insert, delete the preceding word
- Modify VI Text
The number preceding each command indicates the number of times the command has been repeated command substitution operation Rchar Replace the current character with Char R text escape replaces the current character with text until the ESC key is replaced Stext escape Use text instead of the current character s or Cctext escape with text instead of the entire line Cwtext escape change the current word to Text Ctext escape to change the remainder of the current line to text CG escape
- Find and Replace in VI
command Lookup and replace operations/text finds text forward in the file?text searches backwards in the file n in the same direction repeatedly finds N in the opposite direction repeatedly finds Ftext Finds text Ftext forward in the current line, looks backwards in the current line, finds text Ttext in the current line, and positions the cursor in the first character of text Ttext finds text backward in the current line and positions the cursor in the first character of text:SetIC Lookup ignores case:SetNoic is case sensitive when looking for: s/oldtext/NewText replace Oldtext:m,ns with NewText/oldtext/NewText in M line through N, replace with NewText OldText&repeat the last: s command: G/text1/s/text2/Text3 Find rows that contain Text1, replace them with Text3 text2:g/text/command to run commands on all lines that contain text: v/text/command command to run on all lines that do not contain text
-
Copy text in VI
command copy operation YY puts the contents of the current line into a temporary Buffer Nyy the contents of n rows into a temporary buffer p places the text in the temporary buffer into the cursor after P places the text in the temporary buffer into the light Pre-DSFSD " (A-Z) NYY copy n rows into a named buffer with parentheses in the name , omit n to indicate the current line (A-Z) ndd delete n rows put in a name in parentheses A named buffer, omitting n means the current line (A-Z) p to enclose the name as a circle The contents of the named buffer of the number are placed in the current line after the (A-Z) P names a circle The contents of the parentheses of the named buffer are placed before the current line
- Undo and Redo in VI
the command undo action U undoes the last modification U undoes all modifications of the current line. Repeats the last modification, repeating the previous F, F, t, or T lookup commands in the opposite direction ; " NP n repeat the preceding/or? Find command N repeat in the opposite direction the previous
- Save text and Exit VI
Command save and/ or exit Operation: W Save the file but do not exit vi:w. File to save the modification in file but do not exit VI:WQ or ZZ or: x Save the file and exit Vi:q! Do not save the file, Exit Vi:e!
- options in vi
option action: set All print all options: set nooption turn option option off: set Nu Print line number before each line: set Showmode display is input mode or Replace mode: set Noic case is ignored when searching: set list shows tabs (^i) and end-of-line symbols: set ts=8 set tab for text input stops: set window=n Set the text window to display n rows
- Status of VI
option effect:. = Print the line number of the current line:= ^g Displays the file name, the current line number, the total number of rows in the file, and the percentage of the file location: L Use the letter "L "
- Positioning paragraphs and placement marks in text
option Action { Insert {In first column to define a paragraph [[ return to beginning of paragraph]] move forward to the beginning of the next paragraph m (a-z) ' (A-Z) moves the cursor to the specified marker, such as '
- Connecting Rows in VI
Option Action J connects the next line to the end of the current line NJ
- Cursor Placement and screen adjustment
option Action H moves the cursor to the top row of the screen NH moves the cursor to the nth row of M below the top row of the screen Move the cursor to the middle of the screen L move the cursor to the bottom line of the screen NL moves the cursor to line n on the bottom line of the screen^e (Ctrl +e) Roll the screen up one line^y Roll the screen down one line^u Roll the screen up half a page^d Roll the screen down half a page^B Roll the screen up one page^f Roll the screen down one page^l Redraw Screen Z-returnset the current row to the top row of the screen NZ-returnPlace the nth row below the current row as the top row Z of the screen. Place the current row as the central NZ for the screen. Place the nth row on the current line as the center Z of the screen-Place the current row as the bottom line of the screen NZ-Place the nth row on the current line as the bottom row of the screen
- vi
Span style= "color: #000000;" > option action: !command executes command commands for the shell, such as:! ls: !! Execute the previous shell command: R !command Read the command command input and insert, such as: R!
ls executes the LS and reads the contents: W !command the currently edited file as the standard input for the command command and executes the command commands, such as: w!
grep all:cd directory changes the current working directory to the directory represented by directory: SH will start a sub s Hell, use ^d (ctrl+
d) to return Vi:so file to read and execute commands in the Shell program file
-   Macros and abbreviations in VI
(Avoid using control keys and symbols, do not use the characters K, V, G, Q, V, *, =, and function keys)
option Role: Map key COMMAND_SEQ defines a key to run command_seq, such as: Map e ea, whenever you can move E to the end of a word to append text: Map in the status line shows all the fixed Semantic macros: Umap key deletes the macro for the key: AB string1 string2 defines an abbreviation that replaces string2 with string1 when inserting string1. When you want to insert text, type string1 and press ESC, the system inserts STRING2:AB to display all abbreviations: una string to cancel the abbreviation for string
- Indent text in VI
Options ^i (Ctrl +i) or tab insert text, insert moving width, moving width is predefined:set ai turns on auto indent:set sw=n set move width to n characters n<< make n rows move left one width n>>