Vim/Vi practical skills (version 2) and vim Practical Skills

Source: Internet
Author: User

Vim/Vi practical skills (version 2) and vim Practical Skills
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 ixiaofang@163.com <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 xiaofang@qq.com # will be replaced by the following content after each input mymail

 

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.

 


Which prawn knows how to use the alias defined by alias in Vim/Vi?

Vi/vim does not have the concept of alias. What do you mean? I hope you can describe it in detail.

In the linuxde operation, the vi command displays the vim + file name.

Run
Ln/bin/vim/bin/vi
Or write it in your configuration file.
Alias vi = vim

Vi is an old compiler.
Vim is his enhanced version.
In fact, the function is similar.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.