Linux Essential Operation vim

Source: Internet
Author: User

Vim is called the god of the editor, so when we operate the Linux system, does the editing work feel powerless? Today, I am talking about some of the VIM's operational commands I have summed up with you to share, there are shortcomings also please point out.

Three modes of Vim do you remember?

One: command-line mode

1. When you open a file with Vim, it enters the command line mode by default.
2. Cursor movement:
Character-level k down J left H right L
Line level 0 beginning $ line End
Screen level H screen header L screen tail
Line N of document-level G document footer Ng document
Delete operation: (similar to win under the cut operation)
DD deletes the cursor as it moves forward
N+DD Delete a few lines after the cursor
3. Copy:
YY copy cursor when moving forward
N+yy the following lines where the cursor is copied
4. Paste:
P
Two: Edit mode:

1. Ways to enter edit mode

Command line mode--a,i,o,s-> edit mode--esc--> command line mode

In command-line mode, you can enter edit mode by pressing the key a,i,o,s, the difference is as follows--
A enter after the character of the cursor
I enter the character where the cursor is
o Another line where the cursor is located
s cursor where the character is removed into

Three: the tail-line pattern is also called (last-line mode):

1. Ways to enter the tail line mode

In command mode: Enter: Execute the Save and exit commands

W--Write

q--exit

wq--Save and exit

Q!--Force quit does not save

W! --Forced write

Input/Enter tail-line mode, where search and replace operations can be performed

such as/Var (by N and N to find the file "Var" and highlighted)

Replace:

: S/bin/bin---Replace the first word in the row
: s/bin/bin/g---Replace the bin of the row
:%s/bin/bin/g---Replace all bins

IV: Supplement to Additional settings

1. When we look at lengthy content such as log will not be depressed because the line number can not be displayed? Let me introduce you how to display the line number
: Set Nu--Temporary set display line number
: Set Nonu---cancel display
If you want to open it permanently:
1. Create the. VIMRC in the user home directory.
2. Conduct VIM/ROOT/.VIMRC
Enter set Nu and press ESC, WQ Save to exit, the knot opened and found a favor to show it

2.x and WQ functions like save and launch
3.X Encrypt files Be careful not to encrypt the system asking for price
Unlock Password: Set a blank password for password delete operation


4 Tail Line mode
: U undo Previous Step

: Nu Undo N Step
Cancel Undo: Ctrl + R

Linux Essential Operation 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.