Vim/VI Practical Skills
1. Import files
: R [file name] # import to the currently edited File
For example, R/etc/inittab
The upper part of the file is the/etc/services file, and the lower part is the/etc/inittab file.
2. Run the command [do not exit VI]
:! [Command]
:! Ls-L/home/hadoop
Extended-import the command execution result to the currently edited file!
: R! Date
3. Define shortcuts
: Map [shortcut key] [trigger command]
E.g.: Map ^ p I # <ESC> # Ctrl + V Ctrl + P or Ctrl + V + P
: Map ^ o 0x # Delete the first character of a line
: Map ^ e [email protected] <ESC>
Command Execution: Ctrl + P, CTRL + O
Command canceled: unmap ^ P
4. Continuous Line comment
: N1, N2/^/#/G # Add at the beginning of the line from N1 to N2 #
: N1, N2/# // G # Remove the first line from N1 to N2 # Remove
: N1, N2/^ # // G # Remove the first # Number of the row in a row
: % S/^/\/G # Add a // symbol at the beginning of the line
: % S/\ ///G # Remove the beginning of the line //
5. Replacement command
: AB mymail [email protected] # After mymail is entered, it will be replaced by the following content.
Unab mymail
Appendix-VI configuration file
The preceding settings cannot be used after VI is restarted. You need to write them to the configuration file. The vi configuration file is stored in ~ In the home directory, it is. vimrc, but this file does not exist by default. You can copy the/etc/vimrc file and change it after renaming it.
Vim/VI practical skills (version 2)