Linux Essentials -15,linux powerful text editor vim commands in detail

Source: Internet
Author: User

################################################

Vim mode

Edit mode

Input mode

Last-line mode


################################################


Vim

One, open the file

Vim +#: Open the file and locate it on line #

Vim +: Locate the last line

Vim +/pattern: Locates the first match to the beginning of a line


################################################


Mode conversion

Edit > enter

I: Front of the current cursor character, converted to input mode

A: After the current cursor character, convert to input mode

O: Below the current cursor position, create a new row and convert to input mode


I: The beginning of the cursor

A: End of cursor line

O: Above the cursor line, create a new row


Input > Edit

Esc


Edit > Last-line mode


Last line > Edit

Esc


################################################


Two, close the file


Last-line mode

: Q exit

: q! does not save forced exits

: Wq Save and exit equivalent: X

: W Save

: w! Force Save


Edit mode Close File

Zz


Three, move the cursor


1, move characters by character

Move move by line

H

L

J

K

#h #j #l #k


2, moving in a single word

W: The first word of the next word

E: Jumps to the ending of the current or next word

B: The first word of the current word


#w #e #b


3, in-line jump

0 Absolute Beginning

^ First non-null character at beginning of line

$ Absolute Line End


4. Jump between rows

#G: #行

G last line

The last line mode directly to the line number can


Four, turn the screen

Ctrl+f: Next article

Ctrl+b: Previous article


Ctrl+d: The next half of the article

Ctrl+u: The first half of the article


Five, delete a single character

X: Delete a single character after the cursor is located

#x: # Characters after deletion of the cursor


Six, delete command D

#dw #de #db

DD: Deletes the current cursor in the row

#dd: Delete the # line of the current cursor

Last-line mode

Startadd,endadd 1,10d

.: Represents the Forward

$: Last line

+$: Down # line


Seven, Paste command p

P: If the whole row is deleted or copied, paste to the bottom of the line where the cursor is located, and if the copy or delete content is a non-full row, paste to the back of the line character where the cursor is located


P: If the error is copied to the entire line, paste to the bottom of the line where the cursor is located, and paste to the front of the character where the cursor is located if the copied or deleted content is not a whole line


Eight, copy command y

Use the pass D command


Nine, modify: delete content first, then convert to input mode

C: Use pass D


Ten, replace

R: Replace single character

R: Replacement mode


11. Undo Edit Operation

U: Undo Previous Edit Operation

#u: Undo most recent 50 operations

Undo the Undo Action Ctrl+r


12, repeat the previous edit operation

.


13, Visualization mode

V: Select by character

V: Select by rectangle


14: Find

/pattern

? pattern

N

N


XV, find and replace

Use the a command in the last line mode

Addr1,[email protected] @qi

$

%: Full text


16, use Vim to edit multiple files

Vim File1 files2 File3

: Next toggles the next

:p Rev to switch to the next

: Last Toggle

: First Toggles

: QA All exits


17th, split screen display a problem

Ctrl+w s

Ctrl+w V

Toggle cursor between windows

Ctrl+w Arrow

: QA All exits


18th, the Sub-window displays multiple files

Vim-o: Horizontal Split

Vim-o: Vertical Split


19th, save the contents of the current file as another file

: Addr1,addr2w/path/to/somewhere


20th, populate the contents of another file in the current file

: R/path/to/somefile


21st, interacting with the shell

:! Command


22nd, Advanced Topics


1, display or cancel line number

: Set Nu

: Set Nonu


2, display ignores case

: Set IC

: Set Noic


3, Set auto indent

: Set AI

: Set Noai


4, find the text highlighted or canceled

: Set Hlsearch

: Set Nohlsearch


5, syntax highlighting

: Syntax on:

: Syntax off


23, configuration file

[Email protected] ~]# VIM/ETC/VIMRC

[Email protected] ~]# ~/.VIMRC


24th, VIM Learning Handbook

[Email protected] ~]# Vimtutor


This article is from the "James Zhan Linux Advanced ops" blog, so be sure to keep this source http://jameszhan.blog.51cto.com/10980469/1875925

Linux Essentials -15,linux powerful text editor vim commands in detail

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.