Reproduced in: Linux vim three modes

Source: Internet
Author: User
Tags save file

General Mode : Enter the "Vim file name" in the Linux terminal to enter the general mode, but cannot enter the text.

edit mode : Press I in general mode will enter the editing mode, you can write the program, press ESC to return to the general mode.

Command mode : Press in Normal mode: will enter command mode, there will be a colon in the lower left corner, at this point, you can type the command and execute.

Reprint website: http://anxiongbo.blog.51cto.com/805770/163582

I. VIM HighlightAfter entering Vim, enter the following command in normal mode to open the PHP code highlighting: syntax Enable:source $VIMRUNTIME/syntax/php.vim two. VI Common Commands_______________________________________________________ General Mode                               Cursor movement __________________________________________________________h  or   left ARROW key                       The cursor moves one character to the left j  or   down arrow                       cursor moves down one character k  or   up ARROW key                       cursor moves up one character l  or   right ARROW key                       cursor moves right one character Ctrl + f                             Screen forward one page (common) Ctrl + b                              Screen back one page (common) Ctrl + d                             screen forward half page Ctrl + u                              screen back half page +                                     cursor moves to the next column of non-whitespace-                                     cursor moves to the previous column of non-whitespace n<space>                             after the number and then press the SPACEBAR, The cursor will move to the right of this line                                     n characters, such as 20&LT;SPACE&GT, the cursor moves 20 characters to the right 0                                     (This is number 0)   move to the first word of this line prompt (common) $                                     move to the last word in this line prompt (common) h                                     cursor moves to the top line of the screen m                                     cursor moves to the line in the center of the screen l                                     cursor moves to the bottom line of the screen g                                     move to the last line of this file (common) ng                                   Move to the nth row of this file. For example 20G, it will be moved to this file                                       Line 20th (fits: set NU) n<enter>                             Move the cursor down n rows (common) ________________________________________________________________ general mode                               Find Replacement ________________________________________________________________/word                                 look for a string named word before the cursor?word                                 look for a word string named before the cursor:n1,n2s/word1/word2/g                find the Word1 string between N1 and N2, and replace the string with                                       for Word2 (Common): 1, $s/word1/word2/g                  find the Word1 string from the first row to the last row, and replace the string with the                                      for Word2 ( Commonly used): 1, $s/word1/word2/ge                 finds the Word1 string from the first row to the last row and replaces the string with the                                     for Word2, And show the prompt to the user before replacing (confirm) (common) __________________________________________________________________ general mode                               Delete   copy and paste _____________________________________________________________ _____x,x                                 x to remove one character backwards, X to delete one character forward (common) nx                                   Remove n characters backwards dd                                    Delete the entire line where the cursor is located (common) Ndd                                   Delete the row down n rows of the cursor, for example, 20DD deletes 20 rows (common) d1g                                   Delete all data from the row to the first row of the cursor dg                                    Delete all data from the row to the last row of the cursor yy                                    Copy Cursor Line (common) nyy                                   Copy the down n rows of the row where the cursor is located, for example, 20yy copies 20 rows (common) y1g                                   Copy all data from the row to the first row of the cursor yg                                    Copy all data from the row to the last row of the cursor p,p                                  p Pastes the copied data on the next line of the cursor, and P is pasted on the cursor Line (common) j                                     combines data from the row of the cursor with the next row u                                     Restore previous action (common)  ____________________________________________________________________ Edit Mode                            ________________________________________________________ ___________i,i                                 Insert: Inserts the input text at the current cursor position, Characters that already exist are backwards                                      back (Common) a,A                                   add: Begins the input of the next character where the current cursor is located, the existing character                                       will back (common) o,o                                   Insert a new line: Enter a character starting at the beginning of the next line where the cursor is located ( Common) r,r                                  Replace: R replaces the character that the cursor refers to: R will always replace the    & indicated by the cursornbsp;                                 text until ESC is pressed (common) esc                                   exit edit mode, return to General mode (common)  _________ __________________________________________________________ command line mode                             ___________________________________________________________________ :w                                    writing edited data to a hard disk file (Common):w!                                   If the file property is read-only, force the file to be written:q                                    Exit VI (Common):q!                                   If you have modified the file, do not want to save, use! To force exit Do not save file:wq                                  exit after saving, if: wq!, Then quit after force save (Common): W [filename]                        save edit data to another file (similar to saving a new document): R [FILENAME]&NBSP;&NBSP;&NBsp;                     in the edited data, read the data of another argument, that is, the filename                                       file contents appended to the cursor line: Set nu                               Displays the line number, which, when set, displays the line number of the line in front of each line: set nonu                            in contrast to set Nu, N1,n2 w to cancel line number [filename]                   Save the contents of N1 to N2 as filename  this file

 

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.