Lan Yiyun: Text processing tool VIM and common text processing commands

VIM is a powerful text editor that is often used to process text files. The following are common text processing commands in VIM:

  1. Insert text:
    Press the key in Normal mode  ito enter Insert mode, and you can start inserting text at the current cursor position. Press  Escthe key to return to Normal mode.
  2. Save the file:
    Press the key in Normal mode  :, then enter  wq. Press  Enterthe key to save the file and exit VIM. If you just want to save the file without exiting, you can enter  w.
  3. Undo operation:
    Press the key in Normal mode  uto undo the previous operation.
  4. Copy, cut and paste:
    Use in Normal mode  yyto copy the current line, use  ddto cut the current line, and use to  ppaste the copied or cut text at the current cursor position.
  5. Move the cursor:
    In Normal mode, use  h, j, kand lto move the cursor left, down, up, and right respectively. You can also use the arrow keys to move.
  6. Find and Replace:
    Press in Normal mode  /, then enter the text you want to find, press  Enterthe key to start searching. Use  to replace  :%s/old/new/gthe entire file with  .oldnew
  7. Delete text:
    Use in Normal mode to  xdelete the character at the cursor position, and use to  dddelete the current line. Use  dcommands that move the cursor (for example  dw, de) to delete text from the current position to the specified position.
  8. Visualization mode:
    Press the key in Normal mode  vto enter visualization mode, where you can select text. Press  Vto enter line visualization mode and select an entire line of text. Press again  Vto enter block visualization mode and select block text.
  9. Undo and redo:
    Press in Normal mode  uto undo the previous operation, press  Ctrl+rto redo the undone operation.

The above are common text processing commands in VIM. VIM has rich functions and commands that can process text files efficiently. For beginners, it may take some time to become familiar with the operation of VIM, but once you are familiar with the basic commands, your text editing efficiency will be greatly improved.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/133419577