Summary of how to use vim editor

  1. vim is the editor used in the terminal on Ubuntu. For example, enter vi test.c in the terminal to open it.
  2. Enter editing mode "i", general mode "esc"
  3. Move the cursor: Use the up, down, left, and right keys on the keyboard in editing mode. H, J, K, and L are not available. Both methods are available in normal mode.
  4. Copy: Double-click "y" to copy the first line, press "p" to paste in the next line
  5. Enter command line mode with ":"
  6. Enter "set number" in command line mode to display the line number
  7. Copy multiple lines: Press "v", move the cursor to select lines 1-3, press "y", move the cursor to the paste position, and press "p"
  8. Undo, "u" in normal mode, "u+r" to undo
  9. Text search: "/" or "?" plus the string to be searched, such as pressing "/" or "?" to enter the command line mode, "Enter" to start searching, "n" to search for the next
  10. Delete "delete" or "dd" to delete the entire line or "3dd" to delete 3 lines starting from the cursor
  11. The above is a summary of basic usage. If there are any errors or additions, please let us know in the comment area. Welcome to communicate.

Guess you like

Origin blog.csdn.net/shijizai/article/details/128170068