Vim Common operation

Source: Internet
Author: User

Move

0: Number 0, move to the beginning of the cursor

$: Move to the end of the line where the cursor is


Insert

I insert from the cursor without overwriting the contents of the following

A prompt insert from the next word in the cursor position

A is inserted at the end of the line where the cursor is located

o Insert a new line from the next line in the row where the cursor is located

O Insert A new line from the previous line on the row where the cursor is located

R replaces the character at the cursor

R replaces the character at the cursor and remains, overwriting the contents of the following


Delete

x Delete one character backwards, like "delete"

X Delete one character, similar to "backspace"

DD Delete the line where the cursor is located

Ndd:n is a number, starting at the cursor position and deleting n rows down


Copy and paste

YY the line where the cursor is copied

Nyy N is a number, starting at the cursor position and copying n rows down

P Paste to the next line in the cursor position


Search Check

: A, bs/word1/word2/g A, B is the number of rows, which means searching for word1 between rows A through B, and substituting Word2

: 1, $s/word1/word2/g from the first line to the last row, look for word1 and replace with Word2

: 1, $s/word1/word2/gc from the first line to the last row, find the word1 and replace with WORD2, the replacement will appear prompt, to the user to confirm whether to replace

N: Repeat the previous search action, search down

N: Search Up


Save

: Wq Save Exit

: e! To restore a file to an unedited state

ZZ Save exit

Q! Force quit does not save

: W Save As

: R edits data, reads the data into a file, and displays the following line at the current cursor position

: A, B w save the contents of row A to line B as


U : Revert undo last Action

Ctrl+r: Repeat Last Action

. : Repeats last action


: Set NU Displays line number

: Set Nonu Cancel display

Global Display line number: Directly modify/ETC/VIMRC write set Nu and save exit

Current User display: Modify the current user's VIMRC file to add set Nu


Fills the contents of another file into the current file

: R/path/to/somefile

In the vim editing process, you can execute commands

:! COMMAND

Syntax highlighting on/off

: Syntax on/off

Found text highlighting

: Set Hlsearch

: Set Nosearch


Vim Common operation

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.