Vim Common shortcut keys

Source: Internet
Author: User
Tags string find

Basis:
: W Save: q! forced exit not saved: wq! save exit
X Delete the following character x delete the previous character
DD: Delete Row 5DD: Delete 5 rows
J: Remove line breaks to make the next line come up
U: Undo Last Action
I insert before the cursor I insert a at the beginning of the cursor insert a at the end of the line insert
O: Another line below the current line and becomes insert mode
O: Another row above the current line, into insert mode

Move:
$: Move to end of line
^: Move to the beginning of the line, 0 is also
+: Move to the beginning of the next line
-: Move to the beginning of the previous line
33G: Jump To line 33 and press ' ' to return to the original line
GG: File header G: End of File
30%: Jump to 30% of files
H m L "h" means home, "M" is Middle, "L" is last. The upper and lower position of the current screen, and the case can be
Set Number: Sets display line numbers, set Nonumber: Turn off display
: Set ruler to display line numbers in the lower right corner of the window, with the benefit of the above, space saving
ctrl+u\d scroll up \ Down half screen
Ctrl+e\y scroll up \ down one line
ctrl+b\f scroll up \ down one screen (super practical)
/string find String, enter, press N to jump to the next, N, and press the UP/down key to find the previously found record

Changes:
:%s/str1/str2/g replaces str1 for each row as str2
: 10,20s/str1/str2/g replaces str1 from line 10 to line 20 as str2
: Ten, $s/str1/str2/g replace the str1 from line 10 to the last row is str2
: S/str1/str2/g replaces the current line str1 to str2
: 10,$ w test2.cpp Row 10 to the last row, save to Test2.cpp
: R CLASS/USER.HPP reads the contents of the file and inserts it after the current line
R: Replace the current character
YY: Copy one line 5yy: Copy the five elements p paste
d$: Delete the current cursor to the end of the line d^: Delete the current cursor to the beginning

Little Tricks
Bulk Comment:
CTRL + V: Visual block Mode (select the row to comment) Shift+i Enter input mode Enter # ESC to exit
To dismiss a comment:
CTRL + V: Visual block Mode (select the line to be commented) D-Health Delete

When editing text, if you want to temporarily exit text mode, you only need to enter: SH can temporarily exit text mode input exit to return to the current text operation.

Split-screen display editing
: New, newly created file and split screen, toggle shortcut key, ctrl+w
: Spilt horizontal split screen, the current screen is divided into two, horizontal.
: Vsplit Vertical split screen, the current screen is divided into two, vertical.

Vim Common shortcut keys

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.