Vim Editor Shortcut Summary

Source: Internet
Author: User

vi   : visual interface  Visual Interface         Because we frequently write scripts and configure the server, we need a powerful text editor. Vim:vi  improved vi enhanced Vim is a full-screen, modal editor with three modes of VIM mode: Edit mode (Command mode: Copy   Delete   paste   cut   Cursor positioning) input mode (input) The last line mode (in addition to the edit command, many file management commands: Save   Exit, introduce other file content, more than edit mode) default is in edit mode. The patterns can be converted between them. Mode conversion:: Edit mode--input mode i:  in front of the character of the current cursor, to input mode A: After the current cursor is the character of the input mode o: Below the current cursor row, a new row, and into the input mode I: At the beginning of the current cursor line, To input mode A: At the end of the line where the current cursor is located, change to input mode o: Creates a new row above the current cursor line and transitions between input mode modes: Input mode--edit mode ESC edit mode--last line mode-- Edit Mode Press two times ESC1. Open the file  # vim /path/to/somefile if the file exists then open, or new if it does not exist. The  # vim +# inittab quickly opens and positions the cursor to line #.  # vim + inittab quickly opens the file and positions the cursor on the last line.  # vim +/pattern opens the file and navigates to the beginning of the line that is matched to the first pattern (matched characters, patterns, samples) 2. Close File     2.1   Close File:q  exit:wq  Save and exit:q!  do not save Force quit:w  Save:w!  Force save:x == :wq  Save and exit     2.2  close file zz&nbsp in edit mode;: Save and exit 3.  LightMark Positioning (in edit mode)     3.1  character movement (you can quickly move the cursor using   #h   format) H: l&nbsp to the left;: Right j : down  k: Up      #h移动 # characters, press # to move only once   3.2  move W by word: Move to the beginning of the next word e  : Jumps to the ending of the current word or jumps to the final b&nbsp of the next word;: Jumps to the beginning of the current word or the first word      #w移动到第 # words in the first   3.3  Inline jump 0: Jump to the beginning of the line (absolute beginning) ^: Jump to the first non-whitespace character of a line $: Absolute line end   3.4  specify between lines jump GG: Jump to the first line #g: Jump to # line G: last line       The last line mode, directly to the travel number can be   ex: :n , jump to Nth row 4.   turn screen ctrl+f : Turn one screen down ctrl+b: Turn up one screen Ctrl + D: Flip down half screen ctrl+u: Flip up half screen 5.  Delete single character x: delete the single character at the cursor #x: Delete the cursor and the back of the total # characters 6.  the dedicated delete command d : Combination with jump command       Delete Word d0: Delete the current character to the beginning of the line d$: Delete the current character to the end of the row  == D     delete the cursor to the end of the line   #d跳转符: Remove the jump character # Range of #dw    #de    #dbdG: Delete the cursor to the end of all content      Delete Row dd: Delete the line #dd: Delete the line containing the cursor Row n1,n2d: Deletes the N1 to N2 row, deletes the specified range of rows ******** in the last row mode.: Represents the current row +#: Represents the down # line (including the current row) $: Represents the last line +7.  paste command      Small P: If you delete or copy the entire line, paste it below the line where the cursor is located, if you delete or copy it as a non-The entire row is pasted to the back of the character where the cursor is located.      Big P: If you delete or copy the entire line, paste it above the line where the cursor is located, and if you delete or copy it as a non-full row, paste it in front of the character that the cursor is in. 8.  Copy command  y : yank with DYY: Copy single line #yy: Copy # line 9.  Modify: Delete content first, then convert to input mode C: Use with dcccgcgg10.  replace single-character command R &NBSP: Replace a single character r: replace any number of characters from the cursor, ESC exits the Replace command 11.  undo u: Undo previous edit Operation       Continuous u command to undo previous N Word edits # U: Direct undo recent # Edit action Undo Undo:ctrl+r12.  Repeat previous edit operation .13.  visualization mode V: by character selection V: 14.  find/pattern?patternnn:  by rectangular selection set ic  Search 15.  Find and Replace in last-line mode using the    s    command:  %s/old/new/g full-text replacement:  n1,n2s/old/new/g  Specify line substitution, do not ask: n1,n2s/old/new/c  to specify line substitution, ask 16.  Save as: W new_filename   Save as specified file:w  saving modify:wq  Save exit:q!  do not save exit:wq!  save Modify and eject (file owner and root can use) zz:  save changes and exit Tips Summary: 17.   Import a file, or the contents of a command:r filename   18.  do not exit the command:!which  command that edits the query "command line" 19.  Import the execution results of a command into a file:r !date20.  define shortcut keys map ^p  i#<esc>       ^p --> ctrl+v+p  beginningInsert #map ^b 0x Delete line start character 21.  continuous lines comment (actually the replacement between empty   and  #  or  // ):  n1,n2s/^/#/ G&NBSP;&NBSP;&NBSP;&NBSP: Add #: n1,n2s/^#//g   &nbsp to the beginning of a specified line;: Remove multiple lines from the beginning #: n1,n2s/^/\/\//g &NBSP: Add comments  //22.  Replace:ab myemail  [email protected]23.  at the beginning of the line Save the shortcut as a long-term effective shortcut: To create a new  .vimrc  file in the home directory. /home/username/.vimrc     /root/.vimrc


Vim Editor Shortcut Summary

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.