A summary of the use of Vim editor in Linux

Source: Internet
Author: User
Tags exit in

Vim mode:

Edit mode: That is, command mode

Input mode: normal input characters, etc.

Last-line mode: At the end of the document: input or/input, query, modify replace, etc.

Three modes of conversion:

Edit-Input I: in front of the character of the current cursor, switch to input mode;

A: After the character of the current cursor, switch to input mode;

O: At the bottom of the current cursor line, create a new row and switch to input mode;
I: Converted to input mode at the beginning of the line at which the cursor is currently located
A: At the end of the line where the current cursor is located, convert to input mode
O: At the top of the current cursor line, create a new row and switch to input mode;

Input--Edit ESC

Edit-to-last line:

Last line--edit ESC

Operation mode:

First, open the file:

# Vim/path/to/somefile
Vim +#: Open the file and locate it on line #
Vim +: Open the file and navigate to the last line
Vim +/pattern: Open the file and navigate to the beginning of the line that was first matched to the PATTERN

Default in edit mode

Second, close the file
1, the last line mode closed file
: Q exit
: Wq Save and exit
: q! Do not save and exit
: W Save
: w! Forcibly saved
: Wq---: X
2. Exit in edit mode
ZZ: Save and exit

Third, move the cursor

1. Move characters by character

H: Left J: Lower K: Upper L: Right

2. Move in Word units

W: Move to the next word First E: Move to the ending of the next word B: Jump to the beginning of the current or previous word

3. In-line jump

0: Absolute Line ^ The first non-whitespace character of the beginning of the header $ absolute footer

4. Jump between rows

#G: Jump To Line #

G: Jump to the last line

Five, flip screen

CTRL+F: Flip one screen down
Ctrl+b: Turn up one screen

Ctrl+d: Flip Down half screen
Ctrl+u: Flip up half screen

Vi. Delete a single character

X: Delete a single character at the cursor location

#x: Remove the total # characters from the cursor and backwards

Vii. Delete command

The D command is used in combination with the jump command

#dw, #de, #db

DD: Deletes the current cursor in the row

#dd: Delete the # line that contains the line in which the current cursor is located

In the last line mode:

Startadd,endaddd

.: Indicates when the forward

$: Last line

+#: Down # line

Eight, Paste command p

P: How to delete or copy the entire line, paste to the bottom of the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it behind the character of the cursor.

P: If you delete or copy to a positive row, paste to the top of the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it in front of the character that contains the cursor.

Nine, copy command y

Usage with d command

Ten, modify: First delete the content, in the conversion to input mode

Xi. Replace: R, where R is the replacement mode

12. Undo Edit Operation U

U: Undo the previous edit operation

Continuous U-command to undo previous N Edit operations

#u: Undo the last N edit operation directly

Undo last Undo Operation: Ctrl+r

13. Visual operation

V: Select by character

V: Select by rectangle

14. Find

/pattern

? PATTERN

N,n

XV, find and replace

Use the S command in the last-line mode

Addr1,[email Protected]@[email protected]

1,$

%: Full text

16. Use Vim to edit multiple files

Vim FILE1, FILE2, FILE3

: Next switches to the next file

:p Rev Switch to the previous file

: Last switch to final file

: first to switch to file one

Exit: QA All exits

17, split screen display a file

Ctrl+w,s: Horizontal splitter window

Ctrl+w,v: Vertical splitter window

Toggle the cursor between windows

Ctrl+w, W

: QA Closes all windows

18. Edit multiple files in a window

Vim-o: Horizontal Split display

Vim-o: Vertical Split display

19. Save some of the contents of the current file as a different file

: W

: Addr1,addr2w/path/to/some/where

20. Populate the contents of another file in the current file

: R/path/to/somewhere

21. Interacting with the shell

:! COMMAND

22. Advanced Topics

1, display or cancel line number

: Set Number

: Set Nu

: Set Nonu

2. Display ignores or distinguishes character case

: Set ignorecase

: Set IC

: Set Noic

3. Set Auto Indent

: Set Autoindent

: Set AI

: Set Noai

4. Check the found text highlighting or canceling

: Set Hlsearch

: Set Nohlsearch

5. Syntax highlighting

: Syntax on

: Syntax off

23. Configuration Files

/etc/vimrc

~/.vimrc

A summary of the use of Vim editor in Linux

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.