VIM Basic use

Source: Internet
Author: User

Three basic modes: default in edit mode when open

Edit mode: Also called command mode

Input mode: Insert

Last-line mode: Built-in command-line interface


Open File:

# vim [OPTION] ... FILE ...

+#: After opening the file, the cursor is directly at the beginning of line #

If only "+" is used, the cursor is directly to the end of the file

+/pattern: After opening a file, the cursor is at the beginning of the first PATTERN matching line

Mode conversion:

Edit mode--Input mode

I:insert cursor before inserting

A:append after the cursor is appended

O:open open a new line under the cursor line and enter the input mode


I: Input at the beginning of the line where the cursor is

A: Input at the end of the line where the cursor is located

O: Opens a new line on the cursor line and enters input mode

Input mode--edit mode

Esc

Edit Mode--last-line mode

:

Last-line mode--edit mode

Esc

Tips: no direct conversion between the last line mode & input mode

To close a file:

: Q exit

: q! Force exit, discard all modifications

: Wq Save Exit

: X Save exit

: W/path/to/somewhere The current text is saved to the specified file, the file may not exist, but the path must exist

Cursor Jump:

Character Jumps:

H,j,k,l

K: Up

H: Left L: Right

J: Next

#COMMAND: Skips a specified number of characters

#l, #k

Word Jump:

W: The first word of the next word

B: Last or current word header

E: Last or current word ending

#COMMAND: Skips a specified number of words

#w

Inline Jump:

#G: Line #

G: Last line

GG/1G: First line

Jump between sentences:

): The following sentence

(: The previous sentence

Paragraph Jump:

{: Previous paragraph

}: Next Paragraph


Edit command:

Character editing:

X: Delete the single character at the cursor

#x: Remove the # characters after the cursor

XP: Swap the position of the character at the cursor

Replace command:

R: Similar to X

Delete command:

D: Can be combined with the cursor Jump command, to achieve range deletion

D$,d^,d0

De,dw,db

DD, #dd

Paste command:

P: If the buffer is stored as an entire row, paste it below the current row, or append to the cursor if it is a non-full row number

P: If the buffer is stored as an entire row of content, it is pasted above the current row and, if it is a non-full row count, before the insert is pasted into the cursor

Copy command:

Y: similar to D

Change the command:

C: Remove the cursor character and go directly into input mode

Use the same way as D

Other commands:

Visualization mode:

V: Selected by character

V: Selected by row

Use range selection with edit command

Revoke:

U: Undo unsaved edits, default to 15 actions

#u: Specify the number of cancellations

Revert to previous revocation:

Ctrl+r

Repeat the previous edit operation:

.

Turn screen operation:

Crtl+f: Turn one screen at the rear

Crtl+b: Turn one screen to the header

Crtl+d: Turn half-screen to tail

Crtl+u: Turn half screen to the first

Last-line mode:

(1) Address delimitation

: Start,end

#:    #,#:    #,{+/-}#:

.: Current line $: Last line%: Full text

/pat1/,/pat2/:

How to use: followed by Edit command

D,y,w/path/to/somefile

(2) Find

/pattern to the tail to find the pattern

? pattern looks for the pattern to the header

N: Find matching objects in the same direction as the command

N: Find matching objects in the opposite direction of the command

(3) Find and replace

s/Find/replace/modifier

Multi-File mode: use {} When opening a file

In the last line mode, switch to each other:

: Next Next

:p Rev Previous

: Last One

: First One

: Wall Save All

: Qall Quit all

Window Split mode:

Vim-o{o} file1 file2

-O: Horizontal split

-o: Vertical split

Switch:

Ctrl+w,arrow

Single-File window segmentation

ctrl+w,s: Horizontal Split

ctrl+w,v: Vertical Split


Vim's working characteristics:

Configuration file:

Global:/ETC/VIMRC

Personal: ~/.VIMRC does not exist by default and needs to be created

(1) Line number

Display: Set number, the last-line pattern is abbreviated as: Set Nu

Cancel: Set Nonumber,set Nonu

(2) Bracket matching

Match: Set Showmatch,set SM

Cancel: Set NOSM

(3) Auto Indent

Indent: Set AI

Disabled: Set Noai

(4) Highlight Search

Enabled: Set Hlsearch

Disabled: Set Nohlsearch

(5) syntax highlighting

Enabled: Syntax on

OFF: Syntax off

(6) Ignore character case

Ignore: Set IC

No: Set Noic














This article is from the "Smart Young Planck" blog, please be sure to keep this source http://armolee.blog.51cto.com/6288560/1746184

VIM Basic use

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.