Shortcut keys for VIM editor under Linux

Source: Internet
Author: User

Command-line mode:

Cursor Movement:

H cursor shifts one character to the left

J Cursor moves down one character

K Move the cursor up one character

L MOVE the cursor one character to the right

H the top row of the current screen

L the last line of the current screen

M the middle row of the current screen

G Move to the last line of the entire file

GG moves to the first line of the entire file

1G move to the first line of the entire file

NG moves to the entire 30 lines of the file (how many lines are moved to the number of G, i.e. to 20 lines or 20G)

Paste: yy Nyy (indicates how many lines are pasted)

Copy: P

Undo: U Multiple operations for this time into the VIM editor

Delete: dd ndd (delete multiple lines)

X remove one character to the right

Save exit: ZZ

Insert mode:

A: Move one character to the right of the current cursor to insert

I: Current cursor do insert

O: The next line of the current cursor is inserted

A: Insert the line-ending character of the current cursor

I: Insert the line character of the current cursor

O: Insert the previous line of the current cursor

Press ESC to enter command mode

Bottom-line mode:

Press in command mode: Enter the bottom row mode

: Set NU Displays line number

: Set Nonu Cancel line number

:/String to find string from top to bottom

:? string to find string from bottom up

n means to find in the same order in the lookup (with/string mate is down, use with? string is up )

N means to find in reverse order in the lookup ( with the/string mate is up, use with the? string is down )

Find Replacements:

s/old string/new string replaces the first old character of the current line

s/old string/new string/g whole line substitution

Line number m, line number n s/old string/new string/g m row to n all substitutions between rows

/mode 1/,/Mode 2/ s/old string/new string/g mode 1 to pattern 2 Replace all

/mm/,/nn/s/123/456/g mm line to NN line all 123 are replaced by 456

1,$ s/Old string/new string/g can be replaced by full text, $ represents the last line

line number M,+n s/Old string/new string/g from M line start down n line all replace

line number M,-n s/Old string/new string/g from M line to top n row Replace all

Save exit:

W: Save exit

Q: Do not save exit

Wq: Save exit

q!: Force not to save exit

WQ: Force Save exit

X: Save Exit

X: Encrypt exit after save

W/root/file Save as file in/root/directory

M,n W/root/file saves the M rows in a file to n rows as files in the/root/directory

s W >> /root/file append S line to file in/root/directory

R/USR/SHARE/DOC/DHCP-/DHCP + ENTER (writes the DHCP file to the current file)

Command mode can be used!! To append instructions,!! Can add any command and parameters after

Vim +10 filename navigates to line 10th in the file

Vim +/id/file navigates to the row in the file where the ID first appears




Shortcut keys for VIM editor under 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.