Vim usage tips (INSERT, delete, find, copy, paste, cut)

Source: Internet
Author: User

Programmer's favorite editor: Vim
first figure out the three modes of vim:
1. Command mode: Enter the "Vim file name" in the Linux terminal to enter the command mode, but cannot enter the text.
2. Edit mode: Press I in command mode will enter the editing mode, you can write the program, press ESC to return to the command mode.
3. Last line mode: In command mode, press: Enter the last line mode, there will be a colon in the lower left corner, you can type the command and execute.
The following is a simple analysis of three modes:

here are some common tips for vim:
O: Insert the next line in the current row and enter edit mode
O: Insert a row on the current line and enter edit mode
R: Replace the character at the cursor
R: Replace the current character and its characters until you press [ESC]
W Save gg=g Automatic alignment syntax
Set NU: Sets the line number
Set Nonu: Cancel line number
V: Enter the visual

YY: Copy when moving forward
YYY: The current line and the following three rows
P: Paste
Vim use
O: Insert the next line in the current row and enter edit mode
O: Insert a row on the current line and enter edit mode
R: Replace the character at the cursor
W Save gg=g Automatic alignment syntax
R: Replacement mode

YY: Copy when moving forward
YYY: The current line and the following three rows
P: Paste
NYW: copy n words
U: Undo

D: Cut
DD: Cut one line
NDD: Cut n rows

X: Delete the character of the cursor, equivalent to the [delete] function key
X: Delete cursor before character, equivalent to [Backspace]
DD: Delete the line where the cursor is located
DB: Delete cursor at the beginning of the word
DW: Delete the cursor at the end of the word
S: replaces the specified number of characters with the input text starting at the current cursor position
S: Deletes the specified number of rows and replaces them with the input text
D0: Delete to the beginning of the line
D: Delete the cursor at the end of the line
d+}: Delete cursor to next blank line
DG: Delete cursor at end of file

L: Current screen bottom row
H: Current screen header line
M: Current screen middle row
$: Current End of line
0/^: Current beginning of the line
W: Next word Header
B: Previous word
: line number is transferred to the specified line
}: Next blank line
{: Previous blank line
%: Auto Match find
A: Append to the back

VSP + file name Vertical split screen
CTRL+WW: Different screen switching
/+ Find what: Start finding
N: Next target
N: Previous target
59,60s/source/target/g replace all from 59 to 60
%s/Source/destination/g full text replacement
R filename: Test the file at the cursor

csdn:http://blog.csdn.net/qq_38646470/article/details/79643000

Vim usage tips (INSERT, delete, find, copy, paste, cut)

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.