Linux-vim, the most common operation, linuxvim

Source: Internet
Author: User

Linux-vim, the most common operation, linuxvim

1. Open a file

Vim + #: open the file and locate it in line #

Vim +: open the file and navigate to the last line.

Vim +/PATTERN: open the file and locate the first line of the line matched by PATTERN for the first time.


Ii. Close files

: Q exit

: Wq: Save and exit zz in the editing mode equal to: x

: Q! Force exit without saving

: W save

: W! Force save


Iii. Mode Conversion

Edit mode-> input mode

I: Switch to input mode before the character of the current cursor

A: After the character of the current cursor, convert it to the input mode.

O: at the bottom of the row where the current cursor is located, create a new row and convert it to the input mode.

I: Switch to input mode at the beginning of the row where the current cursor is located

A: At the end of the row where the current cursor is located, convert it to the input mode.

O: Create a new row above the row where the current cursor is located and convert it to the input mode.

Input mode-> edit mode

ESC

Edit mode-> last line mode

:

Last line mode-> edit mode

ESC

Edit mode-> visual mode

In visual mode, you can freely select the selected content from the cursor position, and then delete or copy the selected content.



4. move the cursor (editing mode)

1. move by character

H, j, k, l: Left, bottom, top, right

2. Move in words

W: Jump to the beginning of the next word

E: jump to the end of the current or next word

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

3. In-row jump

0: Beginning of the absolute line

^: The first non-blank character at the beginning of the line

$: End of the absolute line

4. jump between lines

# G: Jump to row # in the last line mode: # Just give the row number directly.

G: when the last line is equal to the last line: $


5. Screen flip

Ctrl + d: Flip down half screen

Ctrl + u: half screen up

Ctrl + f: Flip the screen up

Ctrl + B: Flip down the screen


6. Delete

1. delete a single character

X: delete a single character at the cursor

2. Combined use of the d command and the jump command

Dw, de, db delete a word after/before the current cursor

Dd: deletes the row where the current cursor is located.

# Dd: Delete the rows that contain the current cursor


7. copy and paste

1. Copy y to use the same command as d.

2. paste p or P


8. Replacement

R #: Replace the current character #

R: Replacement Mode


9. unedit

U: undo the previous edit operation. You can undo the continuous u command

Ctrl + r: undo the last undo


10. Repeat the previous edit operation

.


11. search and replace

/PATTERN: Search for PATTERN from the beginning of the cursor to the end of the file

? PATTERN: Search for PATTERN from the beginning of the cursor

N: Repeat the previous search command in the same direction.

N: Repeat the previous search command in the reverse direction.

: S/p1/p2/g replace all p1 in the current row with p2

: N1, n2s/p1/p2/g replace all p1 from n1 to n2 with p2

: % S/p1/p2/g replace all p1 in the file with p2










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.