📄 tagsearch.txt
字号:
does use 'wrapscan', which caused tags sometimes not be found). {Vi starts searching in line 2 of another file. It does not find a tag in line 1 of another file when 'wrapscan' is not set}- If the search fails, another try is done ignoring case. If that fails too, a search is done for: "^tagname[ \t]*(" (the tag with '^' prepended and "[ \t]*(" appended). When using function names, this will find the function name when it is in column 0. This will help when the arguments to the function have changed since the tags file was made. If this search also fails another search is done with: "^[#a-zA-Z_].*\<tagname[ \t]*(" This means: A line starting with '#' or an identifier and containing the tag followed by white space and a '('. This will find macro names and function names with a type prepended. {the extra searches are not in Vi}.==============================================================================6. Include file searches *include-search* *definition-search*These commands look for a string in the current file and in all encounteredincluded files (recursively). This can be used to find the definition of avariable, function or macro. If you only want to search in the currentbuffer, use the commands listed at |pattern-searches|.These commands are not available when the |+find_in_path| feature was disabledat compile time.When a line is encountered that includes another file, that file is searchedbefore continuing in the current buffer. Files included by included files arealso searched. When an include file could not be found it is silentlyignored. Use the ":checkpath" command to discover which files could not befound, possibly your 'path' option is not set up correctly. Note: theincluded file is searched, not a buffer that may be editing that file. Onlyfor the current file the lines in the buffer are used.The string can be any keyword or a defined macro. For the keyword any matchwill be found. For defined macros only lines that match with the 'define'option will be found. The default is "^#\s*define", which is for C programs.For other languages you probably want to change this. See 'define' for anexample for C++.When a match is found for a defined macro, the displaying of lines continueswith the next line when a line ends in a backslash.The commands that start with "[" start searching from the start of the currentfile. The commands that start with "]" start at the current cursor position.The 'include' option is used to define a line that includes another file. Thedefault is "\^#\s*include", which is for C programs. Note: Vim does notrecognize C syntax, if the 'include' option matches a line inside"#ifdef/#endif" or inside a comment, it is searched anyway. The 'isfname'option is used to recognize the file name that comes after the matchedpattern.The 'path' option is used to find the directory for the include files thatdo not have an absolute path.The 'comments' option is used for the commands that display a single line orjump to a line. It defines patterns that may start a comment. Those linesare ignored for the search, unless [!] is used. One exception: When the linematches the pattern "^# *define" it is not considered to be a comment.If you want to list matches, and then select one to jump to, you could use amapping to do that for you. Here is an example:> :map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR> *[i*[i Display the first line that contains the keyword under the cursor. The search starts at the beginning of the file. Lines that look like a comment are ignored (see 'comments' option). If a count is given, the count'th matching line is displayed, and comment lines are not ignored. {not in Vi} *]i*]i like "[i", but start at the current cursor position. {not in Vi} *:is* *:isearch*:[range]is[earch][!] [count] [/]pattern[/] Like "[i" and "]i", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *[I*[I Display all lines that contain the keyword under the cursor. Filenames and line numbers are displayed for the found lines. The search starts at the beginning of the file. {not in Vi} *]I*]I like "[I", but start at the current cursor position. {not in Vi} *:il* *:ilist*:[range]il[ist][!] [/]pattern[/] Like "[I" and "]I", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *[_CTRL-I*[ CTRL-I Jump to the first line that contains the keyword under the cursor. The search starts at the beginning of the file. Lines that look like a comment are ignored (see 'comments' option). If a count is given, the count'th matching line is jumped to, and comment lines are not ignored. {not in Vi} *]_CTRL-I*] CTRL-I like "[ CTRL-I", but start at the current cursor position. {not in Vi} *:ij* *:ijump*:[range]ij[ump][!] [count] [/]pattern[/] Like "[ CTRL-I" and "] CTRL-I", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi}CTRL-W CTRL-I *CTRL-W_CTRL-I* *CTRL-W_i*CTRL-W i Open a new window, with the cursor on the first line that contains the keyword under the cursor. The search starts at the beginning of the file. Lines that look like a comment line are ignored (see 'comments' option). If a count is given, the count'th matching line is jumped to, and comment lines are not ignored. {not in Vi} *:isp* *:isplit*:[range]isp[lit][!] [count] [/]pattern[/] Like "CTRL-W i" and "CTRL-W i", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *[d*[d Display the first macro definition that contains the macro under the cursor. The search starts from the beginning of the file. If a count is given, the count'th matching line is displayed. {not in Vi} *]d*]d like "[d", but start at the current cursor position. {not in Vi} *:ds* *:dsearch*:[range]ds[earch][!] [count] [/]pattern[/] Like "[d" and "]d", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *[D*[D Display all macro definitions that contain the macro under the cursor. Filenames and line numbers are displayed for the found lines. The search starts from the beginning of the file. {not in Vi} *]D*]D like "[D", but start at the current cursor position. {not in Vi} *:dl* *:dlist*:[range]dl[ist][!] [/]pattern[/] Like "[D" and "]D", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *[_CTRL-D*[ CTRL-D Jump to the first macro definition that contains the keyword under the cursor. The search starts from the beginning of the file. If a count is given, the count'th matching line is jumped to. {not in Vi} *]_CTRL-D*] CTRL-D like "[ CTRL-D", but start at the current cursor position. {not in Vi} *:dj* *:djump*:[range]dj[ump][!] [count] [/]pattern[/] Like "[ CTRL-D" and "] CTRL-D", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi}CTRL-W CTRL-D *CTRL-W_CTRL-D* *CTRL-W_d*CTRL-W d Open a new window, with the cursor on the first macro definition line that contains the keyword under the cursor. The search starts from the beginning of the file. If a count is given, the count'th matching line is jumped to. {not in Vi} *:dsp* *:dsplit*:[range]dsp[lit][!] [count] [/]pattern[/] Like "CTRL-W d", but search in [range] lines (default: whole file). See |:search-args| for [/] and [!]. {not in Vi} *:che* *:checkpath*:che[ckpath] List all the included files that could not be found. {not in Vi}:che[ckpath]! List all the included files. {not in Vi} *:search-args*Common arguments for the commands above:[!] When included, find matches in lines that are recognized as comments. When excluded, a match is ignored when the line is recognized as a comment (according to 'comments'), or the match is in a C comment (after "//" or inside /* */). Note that a match may be missed if a line is recognized as a comment, but the comment ends halfway the line. And if the line is a comment, but it is not recognized (according to 'comments') a match may be found in it anyway. Example:> /* comment> foobar */ A match for "foobar" is found, because this line is not recognized as a comment (even though syntax highlighting does recognize it). Note: Since a macro definition mostly doesn't look like a comment, the [!] makes no difference for ":dlist", ":dsearch" and ":djump".[/] A pattern can be surrounded by '/'. Without '/' only whole words are matched, using the pattern "\<pattern\>". Only after the second '/' a next command can be appended with '|'. Examples:> :isearch /string/ | echo "the last one"==============================================================================7. 'Grep' and 'Lid' *grep* *lid*Vim can interface with "grep" and grep-like programs (such as the GNUid-utils) in a similar way to its compiler integration. (see |:make| for moreinformation on that.)7.1 Setting up grepIf you have a standard "grep" program installed, the :grep command may wellwork first time with the defaults. The syntax is very similar to the standardcommand:> :grep foo *.cWill search all files with the .c extension for the substring "foo". Thearguments to :grep are passed straight to the "grep" program, so you can usewhatever options your "grep" supports.By default, :grep invokes grep with the -n option (show file and linenumbers). You can change this with the 'grepprg' option. You will need to set'grepprg' if:a) You are using a program that isn't called "grep"b) You have to call grep with a full pathc) You want to pass other options automatically (e.g. case insensitive search.)Once "grep" has executed, Vim parses the results using the 'grepformat'option. This option works in the same way as the 'errorformat' option - seethat for details. You may need to change 'grepformat' from the default if yourgrep outputs in a non-standard format, or you are using some other programwith a special format.Once the results are parsed, Vim loads the first file containing a match andjumps to the appropriate line, in the same way that it jumps to a compilererror in |quickfix| mode. You can then use the |:cnext|, |:clist|, etc.commands to see the other matches.7.2 Using :grep with id-utilsYou can set up :grep to work with the GNU id-utils like this:> set grepprg=lid\ -Rgrep\ -s> set grepformat=%f:%l:%mthen> :grep (regexp)works just as you'd expect.(provided you remembered to mkid first :) vim:tw=78:ts=8:sw=8:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -