Text Editor Vim/vi

Source: Internet
Author: User

Vim/vi features a powerful full-screen text editor. The main is to build, edit, display text.

www.vim.org Building shell Scripts

: Set number causes the file to appear with line numbers

A after the cursor attachment file I insert text before the cursor o back to the cursor insert a new line

A at the end of the bank attachment file I at the beginning of inserting text o insert a new line on the cursor

Command mode:

h←j↓k↑i→$ 0 Move to the beginning of the line h screen above the M screen China l screen lower end

Positioning

: Set number sets line numbers

: Set Nonumber Cancel line number

GG First Line

G Last line

ng to n rows

: N to N rows

Delete

x Delete the character that is located

NX Delete N Characters

DD Deletes the row

NDD Delete multiple lines

A canonical starting line number in Linux VI, terminating line number s

Copy and cut commands to remove and paste

Yy,y copy DD cut current line p glued to current line

Nyy,ny current n rows of ndd currently following n rows p is glued to the current line

Replace and cancel

R replaces the character of the cursor

R replaces characters from the beginning of the cursor

U cancel the previous step as long as it can be undone before saving

Search and Replace commands

/string forward search for specified characters

N Turn backwards

Strictly case-sensitive

N Turn forward

: Set IC can make it case insensitive: set Noic off

n searches for the next occurrence of the specified string

:%s/old/new/g full text replaces specified string old original character new character

: N1,n2s/old/new/g replaces specified string within a certain range

G means no loop confirmation C=check inquiry

Save exit: Wq shift+zz when no write permission: wq! Forcibly save the fallback

: q! Exit without warranty

: W Save a bit

: W/root/home Save As

1. import File: R file name

2. Execute the command in VI:! Command:! Ls/root

1.2 Importing command results to VI

Define shortcut keys: The map shortcut trigger command is similar to macro

: Map ^p i#<esc> at line beginning #, comment one row

: Map ^b 0x Delete a character at the beginning of a line

Continuous line Comment: n! , N2s/^/#/g

: n1,n2s/n#//g ' ^ '--the beginning of the line, for ' # '

: N1,n2s/^\/\//g Escape character

: AB Illidan [email protected]

: R!date Write current time

Define shortcut keys for #表注释 (shell, and profile) to define a shortcut for a quick delete cursor row

^p--->ctrl p=ctrl+v,vtrl+p,ctrl+v+p

Go to #: n1,n2/#//g \ Make it appear as the intent, escape character.

Unab Cancel the AB definition

Unmap, too.

VI settings cannot be saved so you can only edit the VI configuration ~ Home Directory

Host Directory root->/root/home/illidan

The configuration file for VI is ~/.VIMRC

Personalization can be fully written in the configuration file

Text Editor Vim/vi

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.