Usage of the VIM editor

Source: Internet
Author: User

Vim,visual interface Improve is a powerful, highly customizable text editor, full-screen editor, and modal editor.

One, VIM has three modes : edit mode (also called command mode) is the default mode of VIM, insert mode, text modification editing, the last line mode, support a lot of file management commands, can easily perform text management during the editing process.

Second, vim three modes of conversion

Edit---> Insert

i/i: To insert mode at the front/beginning of all characters of the current cursor

A/A: To insert mode at the end of all characters in the current cursor

O/O: Creates a new row below/above the line of the current cursor and transitions to insert mode

Insert---> Edit

ESC key

Edit----> last line

: Enter the last line mode

:! Shell command----execute shell command directly

last line---> Edit

Esc,esc Key

Third, open the file

vim/filespath/Open or create a file

+num: The cursor is on page NUM after opening the file.

+: Open file, cursor positioned on last line

+/pattern: The cursor is at the beginning of the first line that matches the pattern when the file is opened

Iv. closing Files

In the last row mode

: Wq Save Exit

: w! Forcibly saved

: x Save exit

In edit mode

ZZ Save exit

Five, move the cursor

1, character-by-word movement

H L J K Next up

num h/j/k/l moving num characters

2. Move in Word units

W: Move to the beginning of the next word

E: Move to the current or next word ending

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

3, in-line jump

0: The absolute beginning

$: absolute end of line

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

4. Jump between rows

#G jump to line #

G: Jump to the last line

In the last line mode, directly to the travel number to enter

Six, flip screen

Ctrl+f Turn down one screen

Ctrl+b Turn One screen upwards

Ctrl+d: Flip Down half screen

Ctrl+u: Flip up half screen

Vii. Delete a single character

X: Delete a single character at the cursor location

#x: Remove the # characters that are at the cursor and backwards

Viii. Delete command

D

Combined with cursor Jump command

#dw, #de, #db: Deleting # characters

DD: Delete the row of the current cursor

#dd: Delete the line with the cursor and the following # lines

In the last line mode: [STARTADDR,ENDADDR]

. Represents the current row

$ last line

+# Down # line

Nine, Paste command

Vim deleted content is temporarily saved in the cache (limited), the last deleted content can be used to paste

P: If you delete or copy to an entire row, 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 to the back face of the character on which the cursor is located

P: If you delete or copy to an entire row, paste to the top 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

X. Copy command y

Usage with D

Xi. Delete content first, in conversion to input mode

C: Use with D

12. Replace

R: Replace single character

R: Enter replacement mode

12. Undo Edit Operation

U: Undo the previous edit operation

Continuous u can undo the previous n this operation

#u: Undo the first # actions

Undo last Undo Operation: Ctrl+r

13, Repeat the previous edit operation:.

14. Visualization Mode

V; Select by character

V: Select by rectangle

XV, find

/pattern Backward Lookup

? pattern Forward Lookup

n/n page

16. Find and replace

Use the S command in the last-line mode

Option: 1,$ or % Replace full text

17. Open multiple Files

Vim file1 file2 File3

: Next switches to the next file

: prev Switch to previous file

: Last switch to final file

: first to switch to file one

: QA All exits

18, split screen display a file

Ctrl+w,s: Horizontal splitter window

Ctrl+w,v: Vertical splitter window

Toggle cursor between windows: Ctrl+w,arrow

: QA Exits 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

: W

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

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

: R/path/to/somewhere

22. Interacting with the shell

:! COMMAND

23. Other Commands

1. Display or cancel line numbers

: Set Number:set nu

: Set Nonu

2. Display ignores or distinguishes character case

: Set Ignorecase:set IC

: Set Noignorecase:set Noic

3. Set Auto Indent

: Ser autoindent:set ai

: Set Noai

4. Check the found file highlighting or canceling

: Set Hlsearch

: Set Nohlsearch

5. Syntax highlighting

; syntax off

: Syntax on

24. Configuration Files

/etc/vimrc

~/.VIMRC

Modify the default configuration of vim in the configuration file.

This article is from the "A-filled blog" blog, please be sure to keep this source http://laizetian.blog.51cto.com/10728827/1699986

Usage of the VIM editor

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.