VI/Vim command

Source: Internet
Author: User

File Operations

Vim 【VI]// Open an empty file

Vim [VI] a.txt// Open the.txt file in the current directory. If the file does not exist, create a file named a.txt (specify the storage location as the current directory)

Vim [VI] E: \ a.txt// Open the.txt file in the e-inventory directory. If the file does not exist, create a file named a.txt (specify the storage location as E :\)

: W// Save the file

: WQ] // Save and exit

: WQ]E: \ a.txt// Save it to E: \ a.txt and exit

: Q// Exit (if not saved, the exit fails)

: Q!// Do not save, force exit

: Set fileformat?// View the current format-UNIX/DoS

: Set fileformat = Unix// Set the current file to Unix format

Move cursor

H J K L// Left bottom top right

CTRL + F// Next page

CTRL + B// Previous Page

%// Matching brackets-Parentheses/braces

WW] // Jump to the start of the next word

BB] // Jump to the start of the previous word

EE] // Jump to the end of the current word

0^] // ZeroJump to the beginning of the current row

$// Jump to the end of the current row

Gg// Jump to the prefix of the first line

GD// Jump to the variable or function definition at the current cursor

G// Jump to the beginning of the last line of the current file

5G// Jump to the prefix of row 5th

FX// Search for the character X in the current row.

FX// Search for the forward character X in the current row

;// Repeat the last f or F command

,// Search for the forward character X when executing the f or F command

*// Search backward for words under the current cursor

#// Search forward for words under the current cursor

·.// Return the character + period on the tab to the beginning of the line where the last edit is located

H// To the top line of the current screen

M// To the middle line of the current screen

L// To the bottom line of the current screen

Insert mode

I// Insert from the current cursor position

I// Insert from the beginning of the current row

A// Append after the cursor

A// Append at the end of the current row

O// Insert a new row in the next row of the current row

O// Insert a new row in the previous row

CTRL + n// Match the next prompt

CTRL + P// Match the last prompt

ESC// Exit the editing mode.

Visual mode (used to select text)

V// Start the visual mode and move the selected character of the cursor

V// Start the Line visible mode and move the cursor to select the line

CTRL + V// Start the block visual mode

O// Move to the other end of the selected block

U// Convert the selected block to uppercase

O// Move to another corner of the selected block

Aw// Select a word

AB// Select a matching block (such as parentheses, braces, and braces)

AB// Select a matching block with parentheses

IB// Select the content in parentheses

IB// Select the content in braces

>// Shift right

<// Move left

Y// Copy

D// Delete

~// Switch the case sensitivity of the selected block content

Edit

RX// Replace the character at the current cursor with the character X (in non-insert mode)

J// Move the next row to the end of the current row

CC// Delete the content of the current row

CW// Delete the content from the current cursor to the end of the word

C $// Delete the content from the current cursor to the end of the row

S// Delete the current cursor character and switch to insert mode

S// Delete the content of the current row

U// Cancel

CTRL + R// Redo

.// Repeat the last command

~// Case-sensitive conversion of characters under the current cursor

G ~ IW// Case-insensitive conversion of words under the current cursor

Guiw// Convert the words under the current cursor to uppercase

Guiw// Convert the words under the current cursor to lowercase

<// Left indent

>// Right indent

=// Auto indent alignment

Cut, copy, and paste

Dd// Cut (delete) The current row

DW// Cut (delete) The current word

X// Delete the current character

X// Delete the first character of the current cursor

D// Delete the current cursor to the end of the row

YY// Copy the current row

Nyy// Copy n rows from the current row

YW// Copy the content from the current cursor to the end of the word

Y $// Copy the content from the current cursor to the end of the row

P// Insert the copied content after the current cursor

P// Insert the copied content before the current cursor

] P// Insert the copied content with proper indentation

Search and replace

/Hello// Search for the Hello string

? Hello// Search for the Hello string

N// Search for the Next string in the positive direction

N// Search for the Next string in the opposite direction

: % S/Hello/test/g// Replace all the hello in the current file with test globally

: % S/Hello/test/g// Replace all the hello messages in the current file with test globally (confirm one by one)

Multiple files

: E test.txt// Open and edit the test.txt file in the new buffer zone

: Bn// Switch to the next Buffer

: BD// Delete the current buffer (close the file)

: SP test.txt// Open the file in the new buffer and split the form

CTRL + W, CTRL + S// Split the form

CTRL + W, CTRL + W// Switch to a different form

CTRL + W, CTRL + q// Close the current form

CTRL + W, CTRL + V// Vertical Split form

:Tabe test.txt// Edit the file on the new tab

GT// Next tag

GT// Previous tag

: Tabr// Switch to the first tag

: Tabl// Switch to the last tag

: Tabm 3// Switch to the 3rd tags after the current tag

Reference

Concise Vim leveling strategy

Eclipse and VIM Shortcut Keys Desktop

Vim command speed query card

Vim speed query card for programmers

Vim split screen function

Game: Vim adventure

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.