Common Vim/VI operations (version 2)

Source: Internet
Author: User

Colleagues around you are either using vim or Emacs. If you use ultraedit, you are embarrassed to say hello to others. What plug-ins are there? syntax highlighting and spelling check, everything that can be opened to it is a word: Cool.

If you say so, you have to learn how to do it for half a year. Half a year! It's far from getting started. It's good to learn to move the cursor. You don't have to worry about it, it's just moving around !!!

Vim/VI Introduction

VI is installed by default for all Linux/Unix systems, and VIM is installed by default for mainstream Linux systems.

Vim/VI is a powerful full-screen text editor, the most common text editor on Linux/Unix. It is used to create, edit, and display text files; VI supports almost all languages.

Vim/VI has no menu and only commands.

Official Website: www.vim.org

 

Vim/VI Working Mode

 

 

INSERT command

Command function

A attaches text behind the cursor

A adds text at the end of the line

I insert before the cursor

I insert text at the beginning of the line

O Insert a new row under the cursor

O Insert a new line to the cursor

 

 

Locating command

Command function

H shifts one character to the left

J. Move one row down

K move one row up

L move one character to the right

$ Move to the end of a row

0 move to the beginning of the row

 

H move to the top of the screen

M moves to the center of the screen

L move to the bottom of the screen

 

Quick Positioning

Command function

: Set nu display row number

: Set Nonu cancel row number

 

Move Gg to the first line

Move G to the last row

Ng to n

: N to row n

 

DELETE command

X: Delete the cursor character

NX Delete n characters

Dd deletes the row where the cursor is located, and NDD deletes n rows.

DG deletes all rows from the current row to the end of the file, including the current row

D. Delete the content from the cursor position to the end of the line.

: N1, n2d Delete N1 ~ N2 row

 

Copy command

YY and Y copy the current row

Nyy, NY copy n rows

DD: Cut the current row. NDD: Cut the current row and the next n rows.

P paste under the current row

P [uppercase] pasted on the current row

 

Replace or cancel command

R replaces the character at the cursor

R replaces the character from where the cursor is located until ESC ends.

U cancel the previous operation. First, you have not saved the file. The file is still in memory and has not been synchronized to the hard disk.

 

Replace or SEARCH Command

/String: searches for the specified string backward. case-insensitive: Set IC is ignored during search. Cancel: Set noic

N turning back

N forward from the back

 

: % S/old/new/g Replace the specified string in full text, and old is the keyword to be replaced.

: N1, N2s/old/new/g Replace the specified string within a certain range

: % S/old/new/C Replace the specified string in full text, but will ask

 

Save and exit

ZZ: WQ shortcut

: W new_filename save as the specified file

: WQ! Forcibly Save the modification and exit [root/file owner]

: Q! Do not save and exit

Common Vim/VI operations (version 2)

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.