Ubuntu vim terminal editing command 1. after VIM highlights and enters vim, enter the following command in normal mode to enable php code highlighting: syntax enable: source $ VIMRUNTIME/syntax/php. vim 2. VI Common commands www.2cto.com _______________________________________________________ general mode move cursor h or move a character j to the left direction key cursor or move a character k to the downward direction key cursor or move a character l or move the cursor to the right by pressing the right arrow key Ctrl + f. The screen is displayed one page forward (commonly used) ctrl + B screen flip one page (commonly used) Ctrl + d screen flip half page forward Ctrl + u Move the screen half page backward + move the cursor to the next column of the non-space character-move the cursor to the previous column of the non-space character n <space> and then press the space key, the cursor will move the n characters in this line to the right, for example, 20 <space>, the cursor will move 20 characters 0 to the right (this is a number 0) move to the first character (frequently used) of this line $ move to the last character of this line (frequently used) h. move the cursor to the M line at the top of the screen. Move the M cursor to the line in the center of the screen. L move the cursor to the G line at the bottom of the screen to move to the last line of the file (commonly used) nG moves to the nth line of the file. for example, 20 GB will be moved to the 20th rows of the file (can be used with: set nu) n <Enter> move the cursor down n rows (commonly used ________________________________________ ________________________/Word searches for a string named word before the cursor? Word searches for a word string named n1, n2s/word1/word2/g before the cursor and finds the word1 string between line n1 and line n2, replace this string with word2 (commonly used): 1, $ s/word1/word2/g to search for the word1 string from the first line to the last line, and replace this string with word2 (commonly used): 1, $ s/word1/word2/ge searches for the word1 string from the first row to the last row, replaces the string with word2, and displays a prompt for confirmation (confirm) before replacement) (commonly used) www.2cto.com ______________________________________________________________________________________________________________________________________________________________________________ x, X is backward deleted One character, X is to delete one character (commonly used) Forward nx to delete n characters dd to delete the entire line (commonly used) ndd where the cursor is located to delete the next n lines of the row where the cursor is located, for example, 20 dd is to delete 20 rows (commonly used) d1G delete all data from the row where the cursor is located to the first row dG delete all data from the row where the cursor is located to the last row yy copy the row where the cursor is located (commonly used) nyy copies n rows down from the row where the cursor is located. For example, 20 YY copies 20 rows (commonly used) y1G copy all data from the row where the cursor is located to the first row. yG copy all data p from the row where the cursor is located to the last row. P p is the copied data and pasted on the next row of the cursor, P is pasted on the cursor over a row (commonly used) J combines the row where the cursor is located with the data of the next row into a row u to restore the previous action (commonly used ______________________________________________ _____________________ I, I insert: insert the input text at the place where the current cursor is located. The existing characters will be backward (commonly used) a, A added: the input starts from the next character at the place where the current cursor is located. The existing characters will be inserted to the backward (commonly used) o and O lines: enter the character (commonly used) r from the beginning of the next line at the cursor position. Replace R: Replace the character pointed by the cursor: r always replaces the text pointed by the cursor, until you Press Esc (commonly used) to exit the editing mode, return to the general mode (commonly used) ___________________________________________________________________ command line mode www.2cto.com ___________________________________________________________: w write the edited data to the hard disk file (frequently used): w! If the file attribute is read-only, force write to the file: q exit vi (commonly used): q! If you have modified the file and do not want to save it, use it! To force exit without saving the file: wq is saved and then exited. If it is: wq !, After being forcibly saved, exit (commonly used): w [filename] saves the edited data as another file (similar to saving a new file): r [filename] In the edited data, to read the data of another argument, add the file filename to the end of the row where the cursor is located: set nu displays the row number. After setting, the row number is displayed before each row: set nonu is opposite to set nu. To cancel line number n1, n2 w [filename] saves content from n1 to n2 as filename, the file author villion