Use of the VIM editor (case sensitive)

Source: Internet
Author: User
Tags delete cache

At the command line, enter switch to open vim, press I to enter edit mode, start editing text, press ESC to enter command mode.

  Initial use : Open in the graphical interface open vim, press I built, enter the editing mode, edit the text, press ESC to enter the command mode, press: Wq Save and exit, note that command This command has a colon.

  continue to use : Vim mode has 3 types, divided into general mode, edit mode, command line switch mode.

  (1) General mode of the key description:

H Built to move left

J Move Down

K Move Up

L Move Right

CTRL f Move Down one page

CTRL b Move up one page

CTRL D moves down half a page

CTRL u Move Up half page

+ cursor moves to the next line that is not a space

-Move the cursor over a line that is not a space

N <space> N represents a number, plus a space, and how many characters are moved to the current.

0 <space> move to the beginning of a row

H moves to the first character of the upstream,

M moves to the first character of the middle row.

L move to the first character of the line at the bottom of the screen.

G move to last line of file (common)

Ng moves to the first few lines of the file

GG moves to the first line of this file.

n<enter> cursor moves to the first line of this file

/word find the character that the file is woed. Down

Word looks up for a character with word flavor.

n This key is the English key, which means to continue repeating the previous find action,

N This key is the English key, which indicates that the previous find action is repeated to the opposite place.

: n1,n2s/word1/word2/g indicates that word1 of n1-n2 rows is replaced with Word2

: N1, $s/word1/word2/g is replaced by Word2 from the word1 of the last n1-.

: N1, $s/word1/word2/gc function to give confirmation of the replacement.

X Delete the next character that is located in the cursor. Equivalent to the DEL key

NX here n is a number representing the deletion of n characters.

DD deletes the cursor in the row

NDD Delete the row below the cursor line n

D1G deletes all data from the row to the first row of the cursor.

DG deletes all data from the row to the last row of the cursor.

d$ deletes all data from the cursor to that row.

D0 Delete all data from the row to the first row of the cursor

c repeatedly deletes multiple data,

YY Copy all data on the line where the cursor is located

Nyy the next n rows where the cursor is located, N is the number

Y1G Copy all data from the row to the first row of the cursor.

YG copies the data from the row to the last row of the cursor.

Y0 copies all data at the cursor to the first row.

y$ Copy all data from the cursor to the last row.

P Paste the copied data to the following line

P Paste the copied data to the top

J combines the row of the cursor with the next line into a row.

U restores the previous operation.

Ctrl +r repeats the previous action.

  (2) Edit mode:

A common command that goes into edit mode.

I insert from where the cursor is currently located.

I begin by inserting the first non-space where the cursor is currently located.

A inserts from the next character where the cursor is located.

A the last word from the line where the cursor is located is inserted

o Insert a new line from the next line where the cursor is currently located.

O insert a new line at the top of the line where the cursor is currently located.

R enters a replacement insert, which inserts a new line at the next line of the current cursor.

R always replaces the insert until ESC is pressed.

  (2) Command mode

: Wq saves text, and exits if the file does not specify a file name, you need: Wq file name,

: W Write

: wq! Force write.

: Set NU Displays line number

: Set Nonu Cancel line number

: n1,n2 w <filename> Save the contents of N1,N2 to filename this file.

: R <filename> reads the contents of the filename file to the end of the current cursor line.

:! The Commad command is left for the order to leave the current entry command mode temporarily.

Considerations for VIM usage

If you are using VIM editing, Vim will be edited under the file to create a new name FILENAME.SWP file, when the editing process occurs when the vim is not normal, open the edited file will appear warning message, where O is open read-only, E in normal mode open, r load cache file open, d delete cache file Q left vim , a ignores editing behavior.

  Vim's function

The current distributions all use VIM instead of VI function. Terminal input alias can find alias vi= ' vim ', if not, you need to set it yourself.

 Block selection

Press V to make the cursor line to turn white operation, CTRL +V The block to turn white operation, using Y or D operation can be turned white operation, the whole row can be copied.

: n Edit the next file,

: N edits the previous file.

: Files lists all the files that are open for this vime.

  Vim's multi-window function

If the file is large, if you use ctrl+f or use ctr+m to scroll through the file is also very cumbersome, you can cut a file into the display of multiple windows, the command is: SP +filename where only: SP is only split the current file, if it is: sp+ FileName splits multiple files, moves between multiple windows, CTRL +W + J moves down, CTRL +w +K moves up, ctrl +w +q leaves the current window.

­­­­­

  Vim's Environment configuration

: Set Nu Sets line number

: Set Nonu Cancel line number

: Set Hlsearch Setting highlight Lookup

: Set Nohlsearch Cancel Highlight Lookup

: Set Backup

: Set ruler description for the status bar

: Set Showmode whether to display the status bar in the lower left corner

: Set all displays all current environment parameter setting values

: Set displays settings parameters that differ from system default values

: syntax on whether to display different colors according to program-related syntax, open

: syntax off whether an idiom-related grammar shows different colors, off

: Set Bg=dark displays different color tones

: Set Bg=light displays different color tones

: Set autoindent Auto Indent

For these settings, if you want the default settings, this needs to be modified in/ETC/VIMRC, but I heard that it is recommended not to modify this file, modify ~/.VIMRC, default does not exist, create it yourself,

Data source "Bird's private Cuisine".

Use of the VIM editor (case sensitive)

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.