20150830-linux Vim Text Editor

Source: Internet
Author: User
Tags line editor

Occupy position, to be perfected.


Vim Editor:

Full-screen editor: VIM

Vi:visual interface


Sed: line Editor


VI, VI improved


Vim:

Pattern:

Edit mode: Command mode

Input mode:

Last-line mode:


Edit mode--Input mode:

I:insert,

A:append,

O:new Line,

I: The beginning of the line

A: End of line

O: Above New CCB


Input mode--edit mode:

Esc


Edit mode--and last-line mode:

:


Last-line mode--edit mode

Esc


Open VIM:

# VIM

# Vim/path/to/somefile

+#: #为行号;

+/pattern


Turn off VIM:

: Q

: q!

: Wq

: X


ZZ: Save exit


Cursor Jump:

Jump between characters:

H:

L

J:

K:


#COMMAND:


Jump between words:

W: The first word of the 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 beginning of the line;

$: Jump to end of line;


Move between rows:

#G:

1G, GG

G


Move between sentences:

)

(


Move between paragraphs:

}

{


Edit command:


Character editing:

X: Delete the character at the cursor location

#x:


Xp:


R: replaces the character at which the cursor is located;


Delete command:

D:

d^

d$

D0


DW, DE, DB


Dd:


#COMMAND


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


Paste: 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: Above line;


Copy command: Y, yank

Y

y$, y^, y0

Ye, yw, yb


YY: Copying rows


#COMMAND


Changing the command: C, change

C $, c^, C0

CB, CE, CW

Cc:


#COMMAND


To undo a previous edit operation:

U:undo

Undo the previous edit operation;


#u


Ctrl+r:

Redo the previous undo operation


.: Repeats the previous edit operation


Turn screen operation:

Ctrl+f: one screen backward;

Ctrl+b: one screen ahead;


Ctrl+d: Back half screen

Ctrl+u: Forward half screen


Vim built-in tutorials:

Vimtutor


Vim's 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 content that appears in this symbol, to use \ to escape it, use format: \/

The delimiter can be replaced with other characters: @, #等, for example;


Multi-file Mode:

Vim FILE1 FILE2 ...

: Next

: First

:p Rev

: Last


: Wqall

: Q!all


Multi-File Window segmentation:

Vim-o|-o FILE1 FILE2 ...


Ctrl+w, ARROW


Single File Window segmentation:

Ctrl+w, S:split, horizontal split

Ctrl+w, v:vertical, vertical split


Some of the working features of the custom vim:

(1) Line number

Display: Set Nu

Disabled: Set Nonu

(2) Bracket matching

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


: Help for assistance

: Help SUBJECT


The permanent effect of the feature setting is as follows:

Global configuration file:/ETC/VIMRC

User profile: ~/.VIMRC


Practice:

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

CentOS:/etc/grub.conf


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;


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


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


This article is from "I take fleeting chaos" blog, please be sure to keep this source http://tasnrh.blog.51cto.com/4141731/1694474

20150830-linux Vim Text Editor

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.