1. VI is divided into three modes: General mode, edit mode and command line mode. I/esc +: wq:q: q! Enables VI to be converted back and forth in general mode and edit mode.
- /word down looking for a string named word; Word looks up for a string named word.
- X, x: In a line of words, delete one character to the right.
- DD: Deletes the row where the cursor is located.
- YY: The line where the cursor is copied (common)
- Nyy: The next n line where the cursor is copied (common)
- YG: Copy all data from the row to the last row of the cursor
- P: Paste the copied data on the next line of the cursor
- P: Pastes the copied data on the previous line of the cursor
- U: Undo previous action (Common)
- [Ctrl]+r: Redo Last Action (common)
2. General mode is commonly used when switching to edit mode:
I, I enter the insertion mode, I is inserted at the current cursor, I start inserting (common) at the first non-whitespace space where the current row is.
3. General mode switch to command line mode commonly used:
- : W writes the edited data to the hard drive file (common)
- : w! If the file is read-only, force the file to be written, but it depends on what permissions you currently have.
- : Q leave VI (common)
- : q! Force leave without saving files
- : Wq (: wq!) left after saving (forced save)
- : W[filename] Save edited data to another file (similar to save file)
- : Set NU Displays line numbers and line numbers at the beginning of each line
- : Seu Nonu Cancel line number
4. Vim's "Recover" function
Like General software will have the recovery function, vim by saving a temporary file to achieve this function. When we are using vim to edit, VIM will create a new file named. Filename.swp in the edited file directory. If your system is disconnected for some reason and the file you are editing is not yet saved, the. swp file will be able to perform its rescue function.
Vim's language code conversion: ICONV-F originally encoded-t new encoded filename [-o newfile]
Example: Iconv-f big5-t UTF8 vi.big5-o vi.utf8 (convert Vi.big5 to UTF8 encoding)
Some of Vi-vim's forgotten points