The following no special instructions are in command-line mode
1: Turn line numbers on and off
After pressing the Escape key to enter command mode,
: Set number command to turn on line numbers
expand: Enter command mode to &NBSP: set all command displays a list of options and settings.
2: Turn auto indent on and off
Open: Set Autoident
OFF: Set noautoident//shorthand (: Set AI and: Set Noai)
If you enter a space or tab at the beginning of a line, subsequent new rows are indented to the same position. In command mode, enter:set autoindent
, and then press ENTER to turn on automatic indentation. By settingshiftwidth
determines the indentation level. For example:set shiftwidth=4
set each level indent to four spaces. In command mode, you can use >>
commands to add one level of indentation to an existing line, and use <<
commands to reduce one-level indentation. By adding an integer to these commands, you can increase or decrease the one-level indentation for multiple lines.
3: Case-sensitive problem when searching
Case-sensitive: set ignorecase
不区分大小写 :set noignorecase
//Shorthand (:set ic
and the:set noic )
3: Compound search
You can use a simple regular expression to specify that the search keyword contains a word and that the word is followed by another word.
eg:想要找one关键字,在该词后面有0个或者多个更多字符,之后是字符串two的那一行。就写成 /one.*two 然后一敲回车光标就会锁定找到有该两个关键字的第一行,按下n就会找到含有这两个关键字的第二行。前提是这俩个字符串只在一行,才会匹配成功。如果不需要在一行的话,只需要把"."(点)化成";"(分号)即可。对于寻找代码中出现在另一个命令后面的某个命令非常有用,比如在设置某个变量之后调用函数的地方。
This article is from the "Du Qiu _rain" blog, be sure to keep this source http://duqiu.blog.51cto.com/3345942/1576069
Vim tips (In fact, the use of methods, may know less than the number of people)