Common gvim/Vim/VI commands and skills

Source: Internet
Author: User

Common Vim/VI commands:

  • Its replacement function is very useful. For details, see vimreplacement function. html
  • Search for a word:/word, or move the cursor to the word using the * command. Vim will get the word on the cursor and use it as the string to be searched, while # is reverse lookup.
  • [,]: The cursor jumps up and down between empty rows.
  • X or delete indicates DL (delete the characters under the current cursor)
  • X indicates DH (delete the character on the left of the cursor)
  • D Indicates d $ (delete to the end of the row)
  • C Indicates C $ (modified to the end of the line)
  • S indicates Cl (modify one character)
  • S indicates CC (modify a whole line)
  • CTRL-V start the visual mode.
  • Copy: The YW command contains white spaces after the word, the Ye command does not include white spaces after the word, the YY or y Command copies a whole line, and the Y $ Command copies to the end of the line.
  • Delete: The DW command contains the blank characters after the word, and De does not include the blank characters after the word. The DD Command copies the entire line and deletes d $ or D to the end of the line.
  • : W,: WQ,: Q! ,: E! Save, save, and exit, do not save, and re-open.
  • "+ Add YW, ye, YY, Y, y $, P to use the system clipboard.
  • /Pattern -- pattern refers to the content to be searched. VI searches for the first style that matches the specified content in the file.
  • /-- Repeat the previous search
  • % Move the cursor to the matching circle/square brackets
  • : S/pattern1/pattern2 -- replace each content that matches pattern1 in the current row with pattern2
  • : % S/pattern1/pattern2 -- replace each content that matches pattern1 in the entire file with pattern2
  • U undo the previous operation, and CTRL + R repeat the previous operation.
  • N: Repeat the previous search command in the same direction.
  • N: Repeat the previous search command in the reverse direction.
  • Gg moves the cursor to the first line of the file.
  • G move the cursor to the last line of the file. Press Ctrl + V and drag the mouse to select all.
  • = Automatic alignment format.
  • : 966, jump to 966 rows
  • Cscope usage: In the source file directory, cscope-rbkq is generally enough, but sometimes does not work for C ++ and Java. The solution is to execute set_cscope.sh in the source file directory, valid. Then in Vim, click the keywords in crtl + to jump to the definition.
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.