Linux Foundation--vim Editor

Source: Internet
Author: User
Tags exit in

Vim mode:

Edit mode

Input mode

Last-line mode


Mode conversion

Edit-Input

I: Switch to input mode before the current cursor character

A: After the current cursor is in the same character, switch to input mode

o: Insert a row below the current cursor line, and switch to input mode

I: Switch to input mode at the beginning of the current cursor

A: At the end of the current cursor, switch to input mode.

O: Insert a row above the current cursor, and switch to input mode

Input--Edit

Esc

Edit-to-last line


First, open the file

#vim/path/to/somefile

Vim +#: Open the file and navigate to the bottom # line

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

Vim +/pattern: Open the file and navigate to the beginning of the first PATTERN match

Second, close the file

1. Close the file in the last line mode

: Q exit

: Wq Save Exit

: W Save

: w! Force Save

: X Save exit

2. Exit in edit mode

ZZ: Save and exit

Third, move the cursor

1, character-by-word movement

H: Left

L: Right

J: On

K: Next

2. Move in Word units

W: Porting The first word of the next word

E: Jump to the ending of the next word

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

#w: Jump to the beginning of a # Word

3, in-line jump

0: Jump to the beginning of the line

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

$: Jump to end of line

4. Jump between rows

#G: Jump To Line #

G: Jump to the last line

Four, turn the screen

CTRL+F: Flip one screen down

Ctrl+b: Turn up one screen

Ctrl+d: Flip up half screen

Ctrl+u: Flip up half screen

V. Delete a single character

X: Delete a single character at the cursor location

#x: Delete the # characters at and after the cursor

Vi. Delete Commands

#dw: Delete # words backwards

#db: Delete # words forward

DD: Delete the current row

#dd: Delete # lines

In the last row mode: 1,100d means delete 第1-100 row

: 1, $d means to delete all the contents of the file

Seven, paste

P: If you delete or copy to an entire row, paste it below the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it after the character that contains the cursor

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

Viii. Copying commands

Y, use the same as D command

Nine, replacement mode

R: Enter replacement mode

X. Undo Edit Operations

U: Undo Previous Action

#u: Undo Previous # Operations

Xi. Visual mode

V: Select by character

V: Select by rectangle

12. Find

/pattern

N: Find Next time

13. Find and replace

In last-line mode, use the S command

Addr1,addr2s/patern/string/g

14. Use Vim to edit multiple files

Vim FILE1 FILE2 FILE3

: Next switches to the next file

:p Rev Switch to previous file

: Last switch to final file

: first switch to file one

Exit: QA Exits All

XV, split screen display

Ctrl+w, S: Horizontal splitter window

Ctrl+w, V: Vertical splitter window

See Toggle Cursor in Window

Ctrl+w, ARROW

: QA Closes all windows

16, sub-window display multiple files

Vim-o: Horizontal Split display

Vim-o: Vertical Split display

17. Save some contents of the current file as another file

Use the W command in the last row mode

: W

: Addr1,addr2w/path/to/somewgere

18. Fill in the contents of another file into the current file

: R/path/to/somefile

19. Interacting with the shell

:! COMMAND

20, display line number

: Set NU Displays line number

: Set Nonu close line number

: Set IC ignores case sensitive

: Set AI Auto Indent

: Syntax on to turn on syntax highlighting

: Syntax off: Turn off syntax highlighting

21. Configuration Files

/etc/vimrc

~/.vimrc


This article from "Liang Childe" blog, please be sure to keep this source http://iyull.blog.51cto.com/4664834/1884842

Linux Foundation--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.