Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Vim 100Q

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. How to use vim to open a file at the beginning of the 100th line

] # vim + 100FILENAME

two。 How to make vim open a file and locate it at the first if

] # vim + / if FILENAME

3. What are the modes of vim and what are their functions?

Answer: there are edit mode, insert mode, last line mode, visual mode

Edit mode is not only the normal mode, but also the default mode for vim to open files, in which you can perform jump, copy, delete, replace and other operations.

You can enter characters in insert mode. Write a document like a document editor

The last line mode can execute commands, such as highlighting, executing external commands, etc.

In visual mode, you can select lines or characters as needed, and then do something else.

4. Switching of mode tone

a. Normal mode-- > insert mode: you can use I, I, a, A, o, O to switch to insert mode.

I: inserts a character at the current cursor.

I: insert a character at the beginning of the line in which the current cursor is located

A: inserts a character after the current cursor.

A: enter at the end of the line where the current cursor is located

O: open a new line below the current cursor

O: open a new line above the line of the current cursor.

b. Enter mode-- > edit mode, press ESC

c. Edit mode-- > last line mode, enter:

d. Last line mode to edit mode, press ESC keyboard

5. How to save and exit vim

a. In normal mode, enter uppercase ZZ

b. In the last line mode, enter: wq

c. In the last line mode, enter: X

6. How to save a file edited by vim

: w / PATH/TO/SOMEFILE

7. How to exit without saving

a. If the file has not been modified, then: Q does not save and exit

B.: if you modify the file and don't want to save it, just exit and use: Q! Forced exit is not saved.

8. How to make the cursor jump between characters

a. The right-hand hjkl represents left, bottom, top and right, respectively, in normal mode.

b. Using # COMMAND, it means that you can move in a certain direction # times, for example, 21 means to move 2 characters to the right.

9. How to realize the jump between words

A. w, which means moving to the beginning of the next word

B. e, which means to move to the end of the current or next word

C. b, which means to move to the beginning of the current or previous word

D. # COMMAND, meaning to move # words

It should be noted that pressing e in normal mode moves to the end of the word if it is not at the end of the word, or to the end of the next word if it is the end of the word, and so is b.

e. You can also add actions in front of the words before jumping. For example, d2w means to delete the cursor's current position to the prefix of the next two words.

10. How to realize the jump from the beginning to the end of a line

A. ^, which represents the first non-white space character that jumps to the line

B. 0, which means to jump to the absolute beginning of the line

C. $, which means to jump to the end of the line.

11. Interline jump

A. G means to jump to the last line of the file

B. 1G or gg means to jump to the first line of the file

C. # G means to jump to line

D. # j means jump down # lines

E. # k means jump up # lines

twelve。 Intersentence jump and inter-paragraph jump

A.), skip to the next sentence

B. skip to the previous sentence

C.}, skip to the next paragraph

D. {, skip to the previous paragraph

13. Flip screen operation

A. Ctrl+f, flip a screen to the end of the file

B. Ctrl+b, flip a screen to the head of the file

C. Ctrl+u, turn half the screen to the head of the file

D. Ctrl+d, flip half the screen to the end of the file

E. enter key, press the line to flip backwards

14. Character editing (Nornal)

X, in normal mode, indicates that the character at the cursor is deleted.

# x, which means to delete # characters starting at the cursor.

Xp, swapping the position of the character where the cursor is located and the character that follows it.

15. Replace command (Normal)

R: replaces the character where the cursor is located. Using the method rCHAR, type r at the current cursor position, and then enter the character you want to replace with the character you want to replace with CHAR.

R: enter the replacement mode, enter R in normal mode, enter the replacement mode, replace the character where the cursor is located, and then move the cursor to the right, which can be replaced all the time.

16. Delete command

D: d stands for delete, which can be combined with the cursor jump command to delete the range.

Delete: delete the character at the current cursor all the way to the end of the line

D ^: deletes the character at the current cursor (excluding) up to the beginning of the line

De: delete the current cursor to the end of this word or the next word

Dw: deletes the prefix of the current cursor to the next word (excluding the prefix)

Db: delete the current cursor (excluding the current cursor) all the way to the beginning of this word or the previous word

# d [b | e | w]: delete command can be used with jump and numbers to delete multiple words

Dd: delete entire row

# dd: delete multiple lines

17. Paste command (pmenade putjinghouse)

A. P: if the clipboard content is not an entire line, the clipboard contents are inserted after the current cursor; if the entire row, paste on the next line of the current cursor.

B. P: if the clipboard content is not an entire line, the clipboard content is inserted in front of the current cursor; if it is a full row, it is pasted on the previous line of the current cursor.

18. Copy command (yQuery yank)

Y, copy, work behavior is similar to d

Copy: copy the current cursor position up to the end of the line

Y ^: copy the non-white space character at the current cursor position (excluding) up to the beginning of the line

Y0: copy the current cursor position (excluding) to the beginning of the absolute line

Ye: copy the current cursor position to the end of the word

Yw: copy the location of the current light village to the beginning of the next word (excluding the beginning of the word)

Yb: copy the current cursor position (excluding) to the beginning of this word or the previous word

# y [e | w | b]: y can be operated by combining numbers with Motion to indicate that more than one word can be copied at a time

Yy: full line replication

# yy: multiline copy, starting from the current line, copy down # lines together.

19. Rewrite command (change,c):

The edit mode jumps to the input mode to implement the delete operation.

Delete the character from the current cursor to the end of the line and enter Insert mode

C ^: delete the current cursor (excluding) until the beginning of the line and enter Insert mode

C0: delete the current cursor (excluding) until the beginning of the absolute line and enter Insert mode

Cb: delete the current cursor (excluding) to the beginning of this word or the previous word and enter Insert mode

Ce: delete the current cursor until the end of this word or the next word, and enter Insert mode

Cw: deletes the prefix of the current cursor to the next word (excluding the prefix) and enters Insert mode

# COMMAND: can be linked with numbers to indicate that multiple words or lines can be rewritten

Cc: delete the line where the cursor is located and convert to Insert mode

# cc:

20. Undo action

A. uther undo, undo the previous operation

B. U, undo all actions against the bank

C. Ctrl+r, undo the previous undo operation, that is, redo, has been tested not to redo uppercase U undo.

For more training, please visit vimtutor for practical exercises.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report