The VIM editor uses a detailed

Source: Internet
Author: User

650) this.width=650; "src=" http://www.oschina.net/img/logo/Vim_logo.gif?t=1399607809000 "alt=" vim_logo.gif?t= 1399607809000 "/>

    • about Vim :

Vim is a well-known, powerful, highly customizable text editor similar to VI, which improves and adds many features on the basis of VI. Vim is purely free software.

Vim is generally respected as the best of the Class VI editor, in fact the real rivals come from different variants of Emacs. 1999 Emacs was selected as the winner of the LinuxWorld text editing category and Vim was second. But in February 2000 vim won Slashdot Beanie's best Open source Text Editor award, and Emacs was pushed to the second line, with Vim and Emacs also being a very good text editor.

Full-screen editor: VIM, also known as visual Interface, is a text editor, VI, VI improved


    • Vim mode:

Edit mode: Command mode

Input mode:

Last-line mode:


    • Using Vim:

vim [options] [File ...]

# VIM

# Vim/path/to/somefile

+#: #为行号;

+: Quickly navigate to the last line

+/pattern: Quick Match to document


    • Conversion between modes:

Edit mode--Input mode:

I: Current cursor input,

A: The next input of the current cursor,

o: Insert a new line of input,

I: Input at the beginning of the line

A: End of line input,

O: Above new Line input,

Input mode--edit mode

Esc

Edit Mode--last-line mode

:

Last-line mode--edit mode

Esc


    • Turn off VIM:

      Last-line mode:

: Q exit;

: q! Forced exit;

: Wq save and exit;

: x save and exit;


Edit mode:

ZZ: Save exit;


    • Cursor Jump:

Note: The following actions need to be completed in edit mode;

Jump between characters:

K:

H:l: (k, Upper) (J, Bottom) (h, left) (L, right)

J:

#COMMAND: #号代表数字, 5k (represents 5 characters)


Jump between words:

W: The first word of the next word;

E: The ending of the current or subsequent word;

B: The first word of the current or previous word;

#COMMAND:


In-line jump:

^: jumps to the first non-whitespace character at the beginning of a line;

0: Jump to the absolute beginning;

$: Jump to absolute line end;


Move between rows:

#G: 5G (jump to line fifth)

1g,gg

G: End of text (last line)

GG: Text header (first line)


Move between sentences:

)

(


Move between paragraphs:

}

{


    • Edit Commands and actions:

Note: The following actions need to be completed in edit mode;

Character editing:

X: Delete the character at the cursor location

#x: 5x (delete 5 characters after the cursor is located)

XP: Delete and copy

R: the character at which the cursor is replaced, R;


Delete command:

D: Delete command

d^: Delete cursor to beginning of line

d$: Delete cursor to end of line

D0: Removes all characters from the cursor to the beginning of the line

DW, DE, DB

DD: Delete the row (entire row) of the current cursor

#COMMAND: #代表数字

Note: The deleted content will be saved to the buffer by the Vim editor;


Paste command: P (paste, put)

If this copied or deleted content is not a full line

P: Paste at the back of the current cursor;

P: Paste at the front of the current cursor;

If the copied content is a full row (more than one line)

P: Paste below the line where the current cursor is located;

P: Paste to the line above the current cursor;


Copy command: Y, yank

Y: Copy command

y$, y^, y0

Ye, yw, yb

YY: Copying rows

#COMMAND: 5yy (copy 5 rows)


Modify command: C, change

C $, c^, C0

CB, CE, CW

CC: Delete the current row and move to the beginning of the line to turn on input mode

#COMMAND: 5cc (remove cursor below 5 lines and turn on input mode)


Undo command:

U:undo; undo the previous edit operation;

#u: #代表撤销次数

Ctrl+r: Redo previous undo Action (undo Undo, revert undo)

.: Repeats the previous edit operation


    • Flip screen Operation shortcut key:

Ctrl+f: one screen backward;

Ctrl+b: one screen ahead;


Ctrl+d: Back half screen;

Ctrl+u: forward half screen;


    • Multi-file Mode:


Open file: Vim [OptIn] ... [FILE] ...

: Next Next file

: First File

:p Rev Previous File

: Last File

: Wqall all save and exit

: Q!all all forced exit


    • Multi-File Window segmentation:

      Open file: Vim-o|-o FILE1 FILE2 ...

Ctrl+w: Toggle window, multi-file edit window Toggle


    • Single File Window segmentation:

      Ctrl+w, S:split, horizontal split

      Ctrl+w, v:vertical, vertical split

Vim built-in tutorials:

[Email protected] ~]# Vimtutor



Vim last-line mode operations and commands:

Note: The following actions are done in the last line mode

1. Address, delimitation

: Start_pos,end_pos

#: Line #;

#,#

#,+#

.: When moving forward

$: Last line

%: Full text, equivalent to 1,$


/PAT1/: The first time the line is matched to this pattern;

#,/pat1/

/pat1/,/pat2/


After you can follow the edit command:

D, y

W, R


2. Find

/pattern: to the tail

? PATTERN: To the header

N: Same direction as command

N: Opposite direction of command


3. Find and replace

S: In the last line mode, the search and replace operation is done within the bounds of the address;

s/what to look for/replace with content/modifiers

What to look for: Available modes

What to replace: You cannot use a pattern, but you can use a back reference symbol to refer to what the grouping brackets in the preceding pattern match to;

\1, \2, ...

&: Refers to the entire content of the "What to find" matches;

Modifier:

I: Ignore case

G: Global Substitution

/: Used for delimiters, so, to find the content or replace with the contents of this symbol appears, to use \ to escape, using the format: \ \ Delimiter can be replaced with other characters: for example @, #等;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/71/F0/wKioL1XbOFHQHGiNAAFutikKSwI798.jpg "alt=" Wkiol1xbofhqhginaafutikkswi798.jpg "/>


4. Execute commands and import files in VI

In the last line mode:

Import File: R FILENAME

Execute command:! COMMAND

Results of Import execution command: r! COMMAND



    • Customizing some of the working characteristics of vim

1, line number

Display: Set Nu

Disabled: Set Nonu

2. Matching brackets

Display: Set SM

Disabled: Set NOSM

3. Auto Indent:

Set AI

Set Noai

4. Highlight Search

Set Hlsearch

Set Nohlsearch

5. Syntax coloring

Syntax on

Syntax off

6. Ignore character case

Set IC

Set Noic

7.: Help for assistance


    • The permanent effect of the feature setting is as follows:

Global configuration file:/ETC/VIMRC

User profile: ~/.VIMRC


Practice Questions :

1, copy the/etc/grub.cfg configuration file to the/tmp directory, use the Find replacement command to delete the/tmp/grub.cfg file at the beginning of the blank character;

Answer:%s/^[[:space:]]//g

2. Copy the/etc/rc.d/init.d/functions file to the/tmp directory, and add a # to the beginning of the line beginning with a blank character for each line of/tmp/functions with the find replacement command; The original whitespace character is reserved;

Answer:%s/^[[:space:]][[:space:]]/#/g

3, replace the/etc/sysconfig/init in/tmp/functions file is/var/log;

Answer:%s/\/etc\/sysconfig\/init/\/var\/log/g

4. Delete the beginning of the line in the/tmp/functions file so #, and # followed by at least one blank character #;

Answer:%s/^#[[:space:]]//g


This article comes from "doing what you want to do!" "Blog, be sure to keep this provenance http://807257775.blog.51cto.com/2448194/1691120

The VIM editor uses a detailed

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.