Vim advanced usage notes

Source: Internet
Author: User
Tags ranges

I. LinuxCommand mode: Vim filename

Move a cursor at a time

H J K L

Top left bottom right

Intra-row Movement

0To the beginning of the lineD0Or d ^ Delete to the beginning of the line

$To the end of a rowD $Delete to end of line

0 = homeTo the beginning of the line $ = end to the end of the line

G50 GB to 50 lines at the end of the file

GgTo the beginning of the file

A small D or a large D is cut

DdCut the current row

5ddCut 5 rows from the current row

DEmpty cut before moving forward

XDelete a letter

DWCuttingIn addition to the word del word

UOne action in a row is removed at a time.

UUndo all actions in a row

Multi-row, small U ratio, large U Management

YYCopy current row

5yyCopy 5 rows

PStick Paste

ZzSave and exit

ZQDo not save and exit

VimConvert uppercase to lowercase :~ Or U or U

1The entire article is converted to lowercase in uppercase: Gg to the beginning of the file → gug

Gu =Lowercase all selected ranges

G =End of File

2The entire article is converted to uppercase in lowercase: Gg to the beginning of the file → gug

Gu =Uppercase all selected ranges

G =End of File

Ii. Command mode → input mode: by INS/a/I/I/o/R

O add a blank line under the cursor and enter the insert mode

O open a blank line on the cursor and enter the insert mode

R to replace one character

R consecutive replacement of multiple characters

File Content Search:

Operation key function

/Word search for the string "word" in the file from top to bottom"

? Word searches for the string "word" in the file from the bottom up"

N locate the next matched string

N locate the last matched string

Command mode → visual block: press Ctrl + v. For example, select multiple lines and add comments.

# Vim → ^ V → I → # → ESC

# Vim → set nu → ^ V → (100g: current row to 100th rows) → I → # → ESC

3. Command mode → last line mode: by colon

By default, VIM search is case sensitive ,:

: Set ignorecaseCase Insensitive

: Set noignorecaseCase Insensitive

: Set nuOr: set number to display the row number.

: Set NonuOr: Set nonumber does not display the row number.

999Move cursor to 999th rows

Colored or non-colored

: Syntax clearOr: Set syntax = off temporarily disable syntax highlighting

: Syntax enableThe syntax highlighting function is enabled for the current buffer.

: WDo not exit

: W!Violent disk storage does not exit

: W file1Save as file1

 

: QExit normally when no dirty data exists

: Q!Discard dirty data and exit

 

: WQSave and exit normally

: WQ!Store and quit

File Content replacement

Command function

: S/old/newReplace the first old found in the current row with new

: S/old/new/gReplace all the old values found in the current row with new

: #, # S/old/new/gIn the range of "#, #", replace all old with new.

: % S/old/new/gReplace all old values with new values within the entire file range.

: S/old/new/CCommand: The system prompts the user to confirm each replacement action.

File encryption and decryption

Vim T. COpen a file

: X as prompted // Encryption

: WQSave and exit

 

File decryption

Vim T. COpen a file

: Set key =Decryption

: WQSave and exit

View Vim Help

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.