Vim Editing and Command mode practice

Source: Internet
Author: User

Edit mode
i      在光标当前的地方开始编辑文档I      在光标所在的行首开始编辑o     从光标所在的行的下面一行开始编辑O    从光标所在的行的上面一行开始编辑a    在光标所在行的后一个字符开始编辑A    在光标所在行的行末开始编辑
command patterns and practices
查找文件格式:/需要查找的内容如:/dnsmasq 直接回车就可以高亮显示出匹配查找的内容,按n 是查找下一个按N 是往上查找也可以用?查找需要的内容,n和N的用法和/相反命令行模式下的替换1,100s/new/old/g1,100是需要替换的范围,表示1到100行进行替换,s表示行g 是全局替换,即替换匹配到的所有内容1$s/new/old/g  是替换文件内所有的匹配字段如果文件中需要替换一个路径或者有特殊字符的需要脱意字符\或者换一个分割符把脱意字符换成#号代替脱意1,100s#/root#/ROOT#g passwd   将1到最后一行中的/root替换成/ROOT,g立即替换所有的不进行确认wq!   保存退出q!    不保存退出x    退出不跟新mtime时间

Wq and X difference: In the change time when the save exit is the same, when entering a file if nothing is done to directly save the exit words Wq is changed mtime, X is not changed mtime

set number  显示行号                 #缩写set nuset nonumber  取消显示行号     #缩写set nonunohl   取消高亮

Vim Paste Code Auto indent causes sorting to be completely chaotic

Use VIM to open a blank document, and then paste the copied code into it, found that it has automatic indentation function, resulting in the pasted text line is more than one line on the right, looks mess. The quicker solution is to enter: Set Noai Nosi before pasting the document in command line mode.
Then press ' I ' to enter edit mode, and then paste the copied code content so that it does not automatically indent.
In some cases the set Noai Nosi command does not work, and you can try to use set paste to manipulate

Vim Editing and Command mode practice

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.