Installation and use of VIM

Source: Internet
Author: User

First, install VIM.

1. No network conditions

Mount CD to MNT under Mount/dev/mount/mnt

Then use the RPM command to install the rpm-ivh/mnt/packages/vim-common-7.2.411-1.8.el6.i686.rpm/mnt/packages/ vim-enhanced-7.2.411-1.8.el6.i686.rpm


2. Network situation direct Yum install-y vim


3. Use

Vim filename

Vim +n filename navigates to the nth line of the file


Two. Vim uses

1. General Mode

Press ESC to enter general mode


h or arrow key left cursor moves one character to the left

L or arrow key right move one character

Move down one line under J or arrow key

Move up one line on the K or the arrow keys

Ctrl+f screen moves forward one page (common)

Ctrl+b Move backward one page (common)

Ctrl+d move forward half a page

Ctrl+u Move Backward Half page

Ctrl+y Scroll Backward one line

Ctrl+e rolling forward one line


– Move the cursor to the next column in a non-space

+ cursor moves to a column that is not a space

Number+space cursor moves n characters to the right

0 cursor moves to the beginning of the line (common)

$ cursor moves to end of line (common)

H screen at the top row

The middle line of the M screen

L a line below the screen drunk

G Document first line (common)

G End of document line (common)

NG moves to nth row

N+enter moving down n rows (common)


/word Search Word string after cursor (common)

Word string to look for Word before the cursor


x remove one character backward (common)

X Delete one character forward (common)

NX removes n characters backwards

DD Delete cursor line (common)

NDD Delete Cursor is located down n rows

YY copy Cursor Line (common)

NYY copy cursor down n rows (common)

Y1G copy cursor line to first row

YG copy cursor line to last row

P Paste the next line of the cursor (common)

P a row on the line where the cursor is located (common)

J merges the cursor column with the next column

U Restore last action (it's okay)

ZZ If the file has not changed, then do not store away, if the file has been changed, then stored and left


2. Edit mode (Common)

I i insert from the position where the cursor starts

A A is inserted after the cursor position

o Insert a new line, starting at the bottom line of the row where the cursor is located

O Insert a new line, starting with a row on the line where the cursor is located

The character entered after R R will replace the current cursor position character

Characters entered after R R are replaced from the cursor position until ESC exits


3. Command mode

: q:q! exit text Force quit (common)

: w:w! Save Text Force Save (Common)

: Wq Save and exit (common)

: e! Force restore to the original state

: w [filename] Save As

: R [filename] cursor after inserting additional file contents

: Set NU Displays line number

: Set Nonu suppress line numbers

: Nohl Highlight (use after search)

: n1,n2s/word1/word2/g find word1 between n1,n2 rows and replace with Word2, and no G replaces only the first word1 of each row

: 1, $s/word1/word2/g replace all word1 in the document with Word2, no G replaces only the first word1 of each row


Three vim simple configuration

VIM/ETC/VIMRC add at the end of the document

Set Nu always displays line numbers


Set ts=4 Tab key to move 4 characters

Set Expandtab


This article from "Samoyed Sadness" blog, reproduced please contact the author!

Installation and use of VIM

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.