Linux study notes (4) --Commonly used shortcut keys for vi and vim editors

Commonly used shortcut operations

Note: It needs to be done in vim specified mode

1. Copy the current line

In normal mode

  • Move the cursor to the specified line
  • enteryy
  • Then enter p(represents pastepaste)
2. Copy the current line 3 lines down

In normal mode

  • Move the cursor to the specified line
  • enter3yy
  • Then enter p(represents pastepaste)
3. Delete the current line

In normal mode

  • Move the cursor to the specified line
  • enterdd
4. Delete 6 lines below the current line

In normal mode

  • Move the cursor to the specified line
  • enter6dd
5. Quickly jump to the first line of the document

In normal mode

  • Move the cursor to the specified line
  • entergg
6. Quickly jump to the last line of the document

In normal mode

  • Move the cursor to the specified line
  • enterG
6. Quickly jump to the last line of the document

In normal mode

  • Move the cursor to the specified line
  • enterG
7. Quickly jump to line 20 of the document

In normal mode

  • enter20
  • Enter shift+G
8. If you entered "xxxx" or deleted some data by mistake, undo the action.

In normal mode

  • enteru
9. Display the line number of the file

In command mode

  • Enter set nu, press Enter
10. Hide file line numbers

In command mode

  • Enter set nonu, press Enter
11. Quickly search for specified keywords

In command mode

  • Enter /+ keyword and press Enter to search
  • If there are multiple matching keywords, enter nto find the next one

vim keyboard diagram

vim keyboard diagram.png

Guess you like

Origin blog.csdn.net/qq_22255311/article/details/123152942