The VIM editor in Linux is detailed

Source: Internet
Author: User

The VIM editor in Linux is detailed

Vim:visual Interface improved also called full screen editor, modal editor

There are four modes of VIM:

Edit mode (Command mode)

Input mode (insert mode)

Last-line mode

Replacement mode

1. Mode conversion:

Edit mode to enter mode:

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 mode to edit mode: Press the ESC key

Edit mode Goto last line mode: input:

Last-line mode to edit mode: Press ESC, sometimes press two times

2. Open File

Vim file

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

Vim +: Open the file and navigate to the last line

Vim +/mode: Open the file and navigate to the beginning of the line that was first matched to the pattern

In edit mode by default

3. Close the file

Close file in last line mode

: Q exit

: Wq Save and exit

: q! Do not save and exit

: W Save

: w! Forcibly saved

: X with Wq

Close file in edit mode: Press the ZZ key to save and exit

4. Move cursor (edit mode)

4.1, character-by-word movement:

H: Left

L: Right

J: Next

K: Up

#h/l/j/k: Move # characters;

4.2. Move in Word units

W: Jump to the beginning of the next word

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

B: Jump to the beginning of the current or previous word

Note: The front plus number, which represents the multiple of the bounce

4.3, in-line jump:

0: The absolute beginning

^: first non-whitespace character at the beginning of a line

$: absolute end of line

4.4. Jump between rows

#G: Jump to Line #;

G: Last line

GG: Jump to the first line

In the last line mode: directly to the travel number to jump to the specified line

5. 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

6. Delete a single character

X: Delete a single character at the cursor location

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

7. Delete command: D command combination use;

#dw, #de, #db

DD: Deletes the current cursor in the row

#dd: Delete the line containing the line of the current cursor;

In the last line mode:

Start line, end row

.: Indicates when the forward

$: Last line

+#: Down # line

8. Paste Command P

P: If you delete or copy to an entire line, paste it below the line where the cursor is located, and if you copy or delete it as part of the line content,

is pasted to the back of the character where the cursor is located;

P: If you delete or copy to an entire line, paste it above the line where the cursor is located, and if you copy or delete it as part of the line content,

is pasted to the front of the character where the cursor is located;

9. Copy command y

YY: Copy the current cursor in the row

#yy: Copy the # line including the line of the current cursor;

10. Modify: Delete content first, then convert to input mode

CC: Delete the current cursor line and go directly into insert mode

#cc: Delete the # line including the line of the current cursor and go directly into insert mode

11. Replace:

R: Single-character replacement

R: Replacement mode, multi-character substitution

12. Undo Edit Operation U

U: Undo the previous edit operation

The continuous u command undoes the previous n edit operations

#u: Undo Recent # edits directly

Undo the most recent undo action: Ctrl+r

13. Repeat the previous edit operation by point.

14. Visualization Mode

V: Select by character

V: Select by rectangle

15. Find usages like man

/mode? mode

N: Indicates the next word of the match is selected

N: Indicates that the matching previous word is selected

16. Find and replace

Use the S command in the last-line mode, as in the SED command

1,$ means from the first line to the last row

%: Indicates from first line to last row

17. Use Vim to edit multiple files

Vim file 1 File 2 ...

: Next switches to the next file

:p Rev Switch to the previous article

: Last switch to final file

: first to switch to file one

: QA All exits

18. Split-screen display of a file

Ctrl+w, S: Horizontal splitter window

Ctrl+w, V: Vertical splitter window

Toggle the cursor between windows:

Ctrl+w, keyboard up and DOWN ARROW keys

: QA Closes all windows

19. Edit multiple files in a window

Vim-o: Horizontal Split display

Vim-o: Vertical Split display

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

Use the W command in the last row mode

: Address range 1, address range 2w file name

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

: R file Name

22. Interacting with the shell

:! Command

23. Advanced Topics

1. Display or suppress line numbers

: 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: Global configuration file, affecting all users

~/.VIMRC: Personal User profile, does not affect other users


This article is from the "Xavier Willow" blog, please be sure to keep this source http://willow.blog.51cto.com/6574604/1764356

The VIM editor in Linux is 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.