Common Vim operations

Source: Internet
Author: User

To do their best, you must first sharpen your tools.

As an essential tool for Linux development, being able to maximize the effectiveness of VI will inevitably improve our work efficiency. Below are some tips for using vi.

 

1. Position the cursor and scroll through the screen.

Command

Function

$

End of current row

0

Start of the current row

Gg

File Header

G

End of File

10gg
10g

Jump to row 10th

''

These are two back quotes, which are the keys under ESC on the keyboard.
Return to the position before the cursor jump

H

Jump to the first line on the screen

M

Jump to the middle line of the screen

L

Jump to the last line on the screen

GK

The last line on the screen

Gj

The next line shown on the screen

 

In Vim command mode, there are many commands for moving the cursor, which brings us great convenience. The most common method is0And$To position the cursor at the beginning and end of the line.

Frequently UsedGPosition the cursor at the end of the file,GgReturn to the file header. Add a number before the two commands to go to that line, for example10ggWill take you to 10th rows.

''The function is to return to the position before the cursor jump. For example, assume that the cursor is currently in row 10th, press G to the end of the file, and then press ''to return to row 10th.

If you find thatKAndJNot very useful (just click a few lines on the screen), you can try itGKAndGj.

 

2. Copy, cut, and paste.

Command

Function

Dd

Delete current row

YY

Copy current row

D $

Delete content from cursor position to end of line

Yt <

Copy the content from the cursor position to the next "<"
(In addition,CT <Modifying the content from the cursor to "<" is convenient when editing HTML and XML files)

"X copy

Put the copied content into Register x
(X can be one of 26 English letters, case sensitive)

"XP

Paste the content of register x

"+

Special register, read/write system clipboard

: Reg

View the content of each register

 

D. Delete the character from the cursor to the end of the line.


Address: http://www.cnblogs.com/cocowool/archive/2009/04/15/1436619.html

 

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.