Vim Quick Guide

Source: Internet
Author: User
Tags save file

The VI editor has 3 modes: Command mode, input mode, and last line mode. It is important to master these three models:

Command mode: VI starts after the default entry is the command mode, any mode, press the [ESC] key can return to the command mode.
Input mode: can enter characters, at the bottom of the display "--insert--" Mark VI entered the input mode.
last-line mode: Enter ":" in the command mode to enter the mode, there are many good commands in the last line mode.

Save File:
: W Save current file: Wq Save and exit: Q exit: q! force quit does not save

To move the cursor:
J down K up H left L right
W Next word first W treats special symbols as part of a word
B Previous Word first B treats special symbols as part of a word
0 Beginning of line ^ beginning of text (after the beginning of a space) $ end
H page Top m page bottom of Middle L page

Numeric parameters:
You can use numeric parameters to repeat execution. For example:
100j Execute 100 This J key, down 100 lines
GG File header g file end line
< line number >g go to the corresponding line by line number

edit: N for Number
x Delete current character dd Delete current line yy copy current line p after cursor paste p paste before cursor
NDD deletes n rows starting from the current line NX remove three characters to the right at the cursor
u undo the most recent operation, you can use it multiple times to reply to all operations. U Cancel all Operations
yy copies the current line to the cache yw copy the current word y$ copy the current position to the end of the line y^ copy the current position to the beginning of the row
nyy copy n rows nyw copy n each word
If you want to copy the contents of line M to nth: M,ny For example: 3,5y Copy the third row to line fifth to the cache

Find:
find and replace primarily in the last line mode
top-down search/characters to find for example:/work find work
bottom-up lookup? The character you're looking for, such as:? Work find work

Replacement:
: S/old/new replaces the first occurrence of the old in the row with new
: S/old/new/g replaces all occurrences of old in line with new
M,n s/old/new/g replaces all old that appear from line m to nth row
% s/old/new/g replaces the old that appears in the entire article with new
: S/OLD/NEW/GC global replacement and requires user confirmation

get help commands by: helper [Content or command]

Vim Quick Guide

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.