Vim common operation and use method

Source: Internet
Author: User

1. Install Vim

Yum Install-y vim-enhanced

2. Common commands

Display to the first few lines of the file

Vim +10/etc/init.d/iptables (shown to line tenth of the file)

Show the number of file lines

: Set Nu

VIM Tri-Medium mode

General mode

The movement of the cursor

Up or down key

JK (up and down); HL (around)

Ctrl+f (Page down); ctrl+b (Page UP)

GG (Enter the first line of the document); Shift+g (enter the last line of the document)

Shift+4 (Enter the end of the line); 0 or shift+6 (enter the beginning)

Copy, cut, paste

Delete

X key (delete backward); Shift+x (delete forward)

Shear

Pressing the P key after delete copies the entire line of the deletion to the position below the cursor; Shift+p is glued to the cursor

Revoke

U key (can be revoked 50 times)

Anti-revocation

Ctrl+r

Copy

Yy

Visual mode

V (the document can be manipulated in visual mode)

Edit mode

Input characters (i, I, A, A, O, O can be entered in edit mode)

I cursor position into the editing mode, I line into the editing mode, a after the cursor into the editing mode, a cursor line end into the editing mode, O cursor line into the editing mode, O cursor line into the editing mode

Exit edit mode

ESC (exit from edit mode to normal mode)

Command mode

: Wq (Write and exit)

: Set Nu (show line number)

/iptables (search iptables)

? Iptables (search iptables)

: 1, $s/iptables/iptables/g (replace IPTABLES in the full-text row with IPTABLES, and replace globally)

%=1,$ (Full text)

Substitution symbols can also be written as #/etc/sysconfig/#111 #, meaning the same

Vim/etc/init.d/iptables

VI!$ = Vi/etc/init.d/iptables


This article is from the "Coarse bread" blog, make sure to keep this source http://culiangmianbao.blog.51cto.com/10475024/1770444

Vim common operation and use method

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.