Linux vi command Daquan

  

Start the visual editor vi filename from the shell to instruct the shell to start the vi editor and pass the parameter filename to it. If the file currently exists in the current state, the vi editor interprets it as the file to be opened; if there is no such file, the vi compiler creates a new file vi file1 file2 file3 shell passes 3 parameters to vi, vi interprets them as The file to open. You can use the :w command to save the file, use the :n command to access the next file vi +# filename to open the file and move the cursor to the specified line. For example, the command vi +100 records edits the file recordsvi +/the filename from line 100 to open the file and moves the cursor to the line containing the target string. For example, the command vi +/Jason friends starts editing the file friendsview filename from the first line containing the string Jason, opens the file for editing, but refuses to save the changes to the file, unless the w! command is used to move the cursor hjkl to the left Move down, up, and right by one character 0 (zero) Move the cursor to the beginning of the current line ^ (off character) Move the cursor to the beginning of the current line as 0. Move the cursor to the end of the current line ## G Move the cursor to the line specified by the number in front of G. For example, 42G moves the cursor to the 42nd line of the file G Moves the cursor to the last line of the file w Moves the cursor forward to the first letter of the next word e Moves the cursor forward to the last letter b of the next word will The cursor moves back to the first letter of the previous word - position the cursor at the beginning of the previous line + position the cursor to the beginning of the next line |  Position the cursor in the 12th column of the current line L Position the cursor on the bottom line of the screen M Position the cursor to a line in the middle of the screen H Position the cursor on the top line of the screen & rdquo; Two single quotation marks move the cursor to it The previous position cursor positioning command (context) fb moves the cursor forward to the next letter b (or any other specified character) on the current line. Fb moves the cursor back to the previous letter b on the current line. (or the specified character) t# Moves the cursor to the right of the first instance of character # on the current line. For example, the command tM moves the cursor to the right side of the first M on the current line. T# moves the cursor to the left on the current line, and moves it to the previous character/word of the first instance of character #. Move to the next instance of the word word? word Move the cursor back to the previous instance of the word word n ​​Move the cursor to the next instance of the specified mode in the previous command /word or ?word to display the adjustment command Ctrl+D in the display file The lower half of the screen text Ctrl+U displays the upper half of the text in the file Ctrl+F The next screen of the text in the display file Ctrl+B Display the previous screen text in the file Set display options: set number Display the line number as the screen Part of it, but the line number is not part of the file. Its abbreviation is: set nu:set nonumber Clears the line number on the screen. You can also use the abbreviated form: set nonu:set showmode to display append mode information in the lower right corner of the screen: set list displays the dollar sign at the end of each line, and uses Ctrl+I to indicate the tab: set showmatch when typing) or], Move the cursor to match it (or [:set window=value defines the number of lines of text lines displayed on the screen: set autoindent is automatically indented. You can also use the abbreviated form: set ai:set tabstop=value to set the display tabulation The number of space characters in the character. You can also use the abbreviation ts=value:set wrapmargin=value to set the right margin of the display. When the input enters the set margin, the editor automatically returns a carriage return: set ignorecase instructs the editor to search String, and ignore the case of the letters in the target: set Display all options set: set all Show all options that can be set Text delete command dd Delete all text lines of the current cursor #dd Delete #行文字dw Delete one from the text Word #dw Remove #字x from the text x Delete one character at the cursor#x Remove # characters from the text Delete the part behind the cursor on the current line Points: #,#d For example, :12,37d will delete all text between lines 12-37, including lines 12 and 37. The undo command u is undone. The most recent text modification operation is resumed even if the cursor has been moved. In the Linux system, using the undo command again will restore the previous text modification operation. In the BSD vi, the second undo operation will cancel the first undo operation, and restore the text modified before the first undo: redo In the Linux system, cancel the undo operation to recover the text modification. On the standard UNIX system, the second u command cancels the first u command, and the result is a "redo"; if the cursor has not been moved out of the current line after the modification, You can undo all text modifications made to the current line. Add text a to the text (lowercase) Insert text A from the right side of the cursor (uppercase) Add text i (lowercase) from the end of the current line. From the left side of the cursor Start inserting text I (uppercase) Insert text from the beginning of the current line o (lowercase) Open (or insert) a new line O (uppercase) below the cursor Open a new line above the cursor: #r filename For example: 8r Report.old reads the file report.old and puts its contents on the 8th line of the current file. Esc. No matter what command is used to enter the append/insert mode, you can leave the append mode and return to the vi command by pressing the Esc key. Mode Ctrl+V allows input of control characters. Press Ctrl+V and then press Enter to insert Ctrl+M into the file. Modify the text in the file cw Only modify the word at the cursor (delete the word and then enter the append mode) To add text at the position of the deleted word) s (lowercase) Replace a single character S (uppercase) Replace the entire line of text cc Replace the entire line of text (same as S)r Replace the character at the current cursor with the next character entered, and Automatically return to command mode R Put the editor in overwrite mode, replace the character C at the cursor with the entered characters (upper case) Modify the text from the cursor to the end of the line on the line ct# Modify the line from cursor to forward The text between the first target characters. For example, ctY will delete all text from the cursor to the first character Y on the current line, and enter append mode to add text cf# at the position where the text is deleted. Modify the line from the cursor to the first target character. The text between (including the target character). For example, cfY will delete all text from the cursor to the first character Y (including Y) on the current line, and enter append mode to add text cT# at the position where the text is deleted. From the cursor to the back 1 text between the target characters. For example, cTY will delete all text from the cursor to the first character Y on the current line, and enter append mode to add text cF# at the position where the text is deleted. Modify the line from cursor to back to the first target character. The text between (including the target character). For example, cFY will delete all text from the cursor to the first character Y (including Y) on the current line, and enter append mode to add text at the position where the text is deleted.

Copyright © Windows knowledge All Rights Reserved