The Linux Vim editor uses a detailed

Source: Internet
Author: User
Tags delete key

In Linux, the main editor is VI or VIM, this article around vim to do a simple explanation:

The Linux default comes with the VI (VIM) editor, and its packages are:

[email protected] ~]# RPM-QF 'which vi ' vim-minimal-7.2. 411-1.8 . el6.x86_64 [[email protected] ~]# rpm-qf 'which vim ' vim-enhanced-7.2. 411-1.8. el6.x86_64

Vim Editor mode switch:

Command mode, command line mode, edit mode

Command mode:

Character manipulation

I insert before current character

I Line Header Insertion

A after the current character is inserted

A Line End Insertion

ESC exits the current mode

o Insert Next line

O Insert Previous Line

x Delete one character backwards (equivalent to the DELETE key)

X remove one character (equivalent to the BACKSPACE key)

U undo One Step

Row operations

Home key or ^ beginning of line

$ end of Line END key

Ndd Delete n rows (n = number of rows, 1 can be ignored)

n yy copy n rows (n = number of rows, 1 can be ignored)

P Paste the Copy line

Extension: Cut = delete First, then paste

Delete to the beginning of D + HOME or ^

Delete to end of line D + END or $

Word manipulation

DW Deletes a word and moves the cursor to the beginning of the word when it is deleted. Also, if the cursor is not at the beginning of the line, the letter after the cursor is deleted.

YW copy a word

W Toggle Word

Block operation

Big D or d+$ Delete to the end of the line d+^ Delete to the beginning

y+$ Copy to tail y+^ copy to First

V Mode ( multi-line comment for Shell, configuration file may also be used )

Enter V Mode: Ctrl + V.

Multiple lines of comment are required when programming:
1. Note: Ctrl + V enters column edit mode

2 Move the cursor down or up

3 mark the beginning of the line to be annotated

4 then press the uppercase I

5 Insert an annotation, such as "#".

6 Press ESC again and it will all be commented out.

To delete multiple lines of comment:

Delete: Press CTRL + V to enter the column editing mode, move the cursor down or up, select the comments section, and then press D to delete the comment symbol.

Vim command line mode operation

: w Saving Save
: Q did not make any changes, quit quit
: q! Modified, not saved, forced to quit
: Wq Save and exit

: wq! Force save and exit.

Save:

Zz

Change one character: R to correspond to the text

Replace
:%s/this/that the first this of each row is replaced by that
:%s/this/that/g replaces all this in the text with that

% indicates full-text match

S replacement

This original content

That modified content

G all occurrences in a row, none replace only the first occurrence

: 2,5 s/nologin/login/g #替换第二行到第五行中的nologin

N,M indicates the specified line number.

/find:/target n search down, n look up

: Set Nu/nonu #显示行号

To highlight:: Noh or casually find a group of characters that are not

:!ifconfig Call System command

Navigate to a line in vim:

GG positioning to the beginning of the line

G navigates to the last line

#G Navigate to a row

: # Navigate to a row

#gg Navigate to a row

#代表行号

Read other files

: R./sshd_config.bak

Vim opens multiple files:

[Email protected] ~]# Vim-o/etc/passwd/etc/hosts

CTRL+WW switching between files

customizing vim

#vim ~/.VIMRC

Input:

Set Nu

Set history=10

In addition, there are vim cursor positioning ...

Learn old, Mark Mark, study notes

Gedit text Editor in Linux desktop environment, graphical interface (equivalent to Windows Notepad)

Linux Vim Editor using the detailed

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.