VI editor skills

Source: Internet
Author: User
Tags line editor
Vi is actually the visual mode of the ex-line editor. each time the ex-editor displays a row by default, to use the ex command in vi, you must first enter: Enter the ex Mode. Www.2cto. comvi is a visual editor. by default, the vee-eyevi reading is in the command mode, and the vi is in the command mode at the beginning. at this time, all the buttons... vi is actually the visual mode of the ex-line editor. each time the ex-editor displays a row by default, to use the ex command in vi, you must first enter: Enter the ex Mode. Www.2cto.com vi is visual editor, and the default command mode is used for reading vee-eye vi. vi is in command mode at the beginning. at this time, all buttons represent commands, in the insert mode, everything you input is file content. The vi command is case sensitive? Start Search command: used to start all ex commands, because vi is only a visualized ex-line editor, saving files can be in uppercase ZZ or: wq.: Q! And: e! You can restore the result without saving the modification. q will release the vi editor and e will remain in vi directly. w nfilename can save the buffer content in a new file ,:! Linux-comm: Enter the ex editing mode! Then you can enter the linux command to view some information. In the command mode of vi, enter sh to open a new shell and press ctrl-d or exit to return to the original vi command mode, another way is to press ctrl-z to pause vi to enter the unix prompt, and then fg can return to vi. The four hjkl keys on the keyboard are placed together. h: move one character to the left, l: move one character to the right, j: move one line down, k: move one line up, and w: move one word at a time, punctuation is also regarded as a word W: It is also a word that is moved at a time, but punctuation is not counted as a word B: a word is regressed at a time, punctuation is also considered a word B: a word is regressed at a time, but punctuation is not a word G: You can move to the end of the file, 2G, 10G and so on to move to the second, the tenth line I insert a ADD (append) difference: www.2cto.com press I to insert the time Mark will not move, the inserted characters are displayed before the cursor, press a time Mark will move a character, the inserted characters are displayed before the cursor, the most general effect is that the former adds characters before the cursor, and the latter adds characters after the cursor. C. You can use the c command to change the text. in the command mode, use the c? After the command, it will delete the relevant text and automatically enter the insert mode, because it is modified ,? Represents a variety of character combinations. Cw delete from cursor to end of word c0 delete from cursor to beginning of line character c $ delete from cursor to end of line (test failed) cc deletes a whole line of text, and then begins to insert new text. r is also a change character. Once you change one character at a time, the interface will not change after you press r. simply enter the character to be changed, only one character can be changed at a time. he does not enter the insert mode. after the change, the R character is also changed in command mode. he can change the entire line of characters at a time. after pressing R, the screen will show the switch to REPLACE mode d to delete text d?? It can be a variety of text objects. dw deletes a word, and the spaces followed by the word will also be deleted. de deletes a word, but the spaces after the word will keep dd to delete a whole line, 2dd and 6dd indicate to delete 2 rows and 6 rows x delete a character u. you can cancel the action vi. moving text is a combination of delete and paste. when moving text, the text is first deleted and placed in the memory buffer, next, move to another position and paste it to the new position. the paste command is p. The small p places the content after the cursor, and the large P places the content before the cursor. Www.2cto.com dd + p dd + P move a row to a row or copy the text in vi before it is a combination of drag and drop + paste. The y drag command can also be combined with other commands to indicate how much content to copy, it is generally used to copy a row of yy + p. each operation command and content will be stored in the temporary buffer until the next operation command ends. Therefore, we can use periods (.) repeat this command to restore the content with p. Vi has nine delete buffers. the last deleted content is placed in buffer 1, and the last two are buffer 2, and so on. the format to be restored is: "np n indicates the buffer, and the buffer content appears after the cursor. Small-scale deletion will not save any row in the buffer zone. Vi has 26 drag-and-drop buffers (named after a-z). y and d can be used with 26 letters. yy indicates to copy a row into the buffer zone, "cyy indicates that the content is placed in the buffer zone named c." c6yy indicates that the subsequent six lines of content are placed in the buffer zone named c, "cp places the content of the buffer named c after the cursor," J capital before the cursor can merge two rows of content. The following code indicates merging 6 rows of content at a time. the above is just an introduction... search mode:/search forward? The backward search mode is retained in the session. you can use n/N to reuse the previous search mode. n is the same direction and N is the reverse direction of the search G jump command, the default G jumps to the end of the file. you can use the row number to move the cursor to the specified row in the file. G accepts the row number as the parameter to jump and input two backquotes ('') you can jump to a pair of quotation marks ('') at the cursor of the previous row or jump back to the original row. However, the cursor position is not the original position, but flashes at the beginning of the row. (You cannot use ''or'' to return the result after you perform other operations between the rows before the redirection.) use vi to open the file www.2cto.com vi file to open the file, the cursor position opens the file vi + n file in the first line of the line vi + file in the last line open the file vi-/pattern file in the nth line open the file at the first match pattern, if there are spaces in the mode, use ''and" "to enclose vi-R file/view file. open the file in read-only mode and enter w! Will be converted from read-only mode to writable mode vi-r can save the content of the cache area, after the system crashes, you can restore the file author mastiff-split which
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.