Frequently used commands for linuxvi editing

Source: Internet
Author: User
There are three state modes in the commonly used command vi editor for linuxvi editing. command Mode 2. input Mode 3. interaction between three modes in last line mode vi editor starts and exits and directly enters the editing environment $ vi enters the editing environment and opens the (new) file $ vimyfile exits v... there are three state modes in the vi editor, which are commonly used commands for Editing linux vi. command Mode 2. input Mode 3. interaction between three modes in last line mode vi editor starts and exits and directly enters the editing environment $ vi enters the editing environment and opens (new) file $ vi myfile exit vi editing environment enter the last line command to discard modifications to the file and exit the editor: q! Save and save files save changes to the opened files in the vi editor: w save as a file save the content in the vi editor as a specified File name: w myfile exit vi editor multiple methods unmodified exit do not modify the files opened in vi editor, or have saved the changes, directly exit vi editor: q: Save and exit vi editor. save the files and exit vi editor. if wq is not saved, quit modifying the file content and exit vi editor: q! Cursor movement and page flip operation type cursor operation key function cursor movement h move cursor to left l move cursor to right k move cursor to move cursor j move cursor down flip Ctrl + f move forward entire page Ctrl + B ctrl + u Ctrl + d jump to the left-side navigation pane quickly jump to the right of the row ^ jump the cursor to the first character of the row $ jump the cursor to the end of the row w. quickly jump the cursor to the first letter of the last word in the current cursor position B. quickly jump the cursor to the first letter of the previous word in the current cursor position e. quickly jump the cursor to the position of the current cursor quick Jump command between the last letter file of the last word: set nu shows the row number in the editor: set nonu cancel the line number in the editor show 1G jump to the first line of the file G jump to the end line of the file # G jump to the first line of the file # enter the input mode command function I enter the insert status at the current cursor after the current cursor enters the insert status A, move the cursor to the end of the row of the current row, and enter the insert status O insert a new row under the current row, move the cursor to the first row of the new row, enter the insert status O insert a new row above the current row, move the cursor to the first row of the new row, enter the insert status cw delete the characters from the current cursor to the end of the word, and enter the insert status c $ delete the characters from the current cursor to the end of the line, and enter the insert status c ^ command to delete the characters from the beginning of the line before the current cursor (excluding the characters on the cursor, and enter the insert status input mode Edit key operation button function direction key move the cursor up and down the left and right direction Home fast locate the cursor to the beginning of the line End quickly locate the cursor to the End of the line PageUp text up pages PageDown to delete the character Del on the left of the cursor delete the character delete operation command function x delete a single character dd at the cursor delete the row dw where the cursor is located delete the current character to the end of the word (including spaces) all characters in de delete the current character to the end of the word (excluding spaces at the end of the word) all characters d $ delete all characters from the current character to the end of the line d ^ delete all characters from the current character to the beginning of the line J delete light The line break at the end of the row where the mark is located. it is equivalent to merging the content of the current row and the next row. the undo operation command function u cancels the last operation, and the recovery operation results can be restored multiple times using the u command to restore the ongoing multi-step operations U cancel all operations on the current row Ctrl + r to use the u command to cancel the operation to restore the copy and paste operation command function yy copy the content of the entire line of the current line to the vi buffer yw copy the content of the current cursor to the end of the word to the vi buffer y $ copy the content of the current cursor to the end of the line to vi buffer y ^ copy the content from the current cursor to the beginning of the line to the vi buffer p read the content in the vi buffer, and paste it to the current position of the cursor (does not overwrite the existing content of the file) string search operation command function/word search from top to bottom in the file string "word "? Word search string "word" n from the bottom up in the file locate the next matched searched string N locate the previous matched searched string replacement operation command function: s/old/new replace the first character "old" string found in the current row with "new ": s/old/new/g replace all the strings "old" found in the current row with "new": #, # s/old/new/g in the row number "#, # Replace all strings "old" with "new" in the "range ": % s/old/new/g replace all strings "old" with "new" within the entire file range: s/old/new/c add the c command at the end of the replacement command, there will be a confirmation of each replacement action prompting the user of the vi editor's online help using vi online help the software package to be installed vim-common-6.3.035-3.i386.rpm software package two ways to use vi online help on the 2nd installation discs in RHEL5 in the vi editor, press the F1 key and enter the last line of help command: help
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.