|
|
| Line 4: |
Line 4: |
| |
|previous=8 |
|
|previous=8 |
| |
|next=10 |
|
|next=10 |
| − |
|created=February 24, 2001 |
+ |
|created=2001 |
| |
|complexity=basic |
|
|complexity=basic |
| |
|author=[[User:Yegappan|Yegappan]] |
|
|author=[[User:Yegappan|Yegappan]] |
| Line 12: |
Line 12: |
| |
|category2= |
|
|category2= |
| |
}} |
|
}} |
| − |
To display the definition of a variable, place the cursor on the variable and use the <tt>[i</tt> command. |
+ |
To display the definition of a variable, place the cursor on the variable and use the <code>[i</code> command. |
| |
|
|
|
| − |
To display a macro definition, place the cursor on the macro name and use the <tt>[d</tt> command. |
+ |
To display a macro definition, place the cursor on the macro name and use the <code>[d</code> command. |
| |
|
|
|
| − |
To display all the lines containing the variable name under the cursor, use the <tt>[I</tt> command. |
+ |
To display all the lines containing the variable name under the cursor, use the <code>[I</code> command. |
| |
|
|
|
| |
These commands work by literally searching for the text. So they work in most, but not all, cases. |
|
These commands work by literally searching for the text. So they work in most, but not all, cases. |
| |
|
|
|
| − |
;<tt>[I</tt> |
+ |
;<code>[I</code> |
| |
:List lines in this file, and in included files, containing keyword under cursor. |
|
:List lines in this file, and in included files, containing keyword under cursor. |
| − |
:The meaning of ''included'' depends on settings, but defaults are set for C (with search of directories normally used for <tt>#include</tt>). |
+ |
:The meaning of ''included'' depends on settings, but defaults are set for C (with search of directories normally used for <code>#include</code>). |
| |
|
|
|
| − |
;<tt>[<C-i></tt> |
+ |
;<code>[<C-i></code> |
| |
:Jump to first match (first line in file containing keyword). |
|
:Jump to first match (first line in file containing keyword). |
| − |
:Ctrl-i is Tab, so, <tt>[<Tab></tt> also jumps to the first match. |
+ |
:Ctrl-i is Tab, so, <code>[<Tab></code> also jumps to the first match. |
| |
|
|
|
| − |
;<tt>]<C-i></tt> |
+ |
;<code>]<C-i></code> |
| |
:Jump to next match (first line after cursor containing keyword). |
|
:Jump to next match (first line after cursor containing keyword). |
| |
:This follows the <C-i>/<C-o> jumping patterns. |
|
:This follows the <C-i>/<C-o> jumping patterns. |
| |
:Prepend the windowing operator (Ctrl-w) to open in a new window. |
|
:Prepend the windowing operator (Ctrl-w) to open in a new window. |
| |
|
|
|
| − |
;<tt>gd</tt> |
+ |
;<code>gd</code> |
| |
:Go to definition of local variable (first occurrence of keyword in current function). |
|
:Go to definition of local variable (first occurrence of keyword in current function). |
| |
|
|
|
| − |
;<tt>gD</tt> |
+ |
;<code>gD</code> |
| |
:Go to definition of global variable (first occurrence of keyword in current file). |
|
:Go to definition of global variable (first occurrence of keyword in current file). |
| |
|
|
|
| Line 52: |
Line 52: |
| |
|
|
|
| |
==Search in files== |
|
==Search in files== |
| − |
Use <tt>:grep</tt> or <tt>:vimgrep</tt> to search for a pattern in files. See [[VimTip1543|Find in files within Vim]]. |
+ |
Use <code>:grep</code> or <code>:vimgrep</code> to search for a pattern in files. See [[VimTip1543|Find in files within Vim]]. |
| |
|
|
|
| |
<pre> |
|
<pre> |
| Line 59: |
Line 59: |
| |
</pre> |
|
</pre> |
| |
|
|
|
| − |
You can omit <tt><CR></tt> for manual changing the file pattern before searching. |
+ |
You can omit <code><CR></code> for manual changing the file pattern before searching. |
| |
|
|
|
| − |
If you have configured <tt>set grepprg=mygrep\ -n</tt> then you can use quickfix mode for jumping to the found locations. |
+ |
If you have configured <code>set grepprg=mygrep\ -n</code> then you can use quickfix mode for jumping to the found locations. |
| |
|
|
|
| |
==Comments== |
|
==Comments== |
To display the definition of a variable, place the cursor on the variable and use the [i command.
To display a macro definition, place the cursor on the macro name and use the [d command.
To display all the lines containing the variable name under the cursor, use the [I command.
These commands work by literally searching for the text. So they work in most, but not all, cases.
[I
- List lines in this file, and in included files, containing keyword under cursor.
- The meaning of included depends on settings, but defaults are set for C (with search of directories normally used for
#include).
[<C-i>
- Jump to first match (first line in file containing keyword).
- Ctrl-i is Tab, so,
[<Tab> also jumps to the first match.
]<C-i>
- Jump to next match (first line after cursor containing keyword).
- This follows the <C-i>/<C-o> jumping patterns.
- Prepend the windowing operator (Ctrl-w) to open in a new window.
gd
- Go to definition of local variable (first occurrence of keyword in current function).
gD
- Go to definition of global variable (first occurrence of keyword in current file).
References
Edit
Search in files
Edit
Use :grep or :vimgrep to search for a pattern in files. See Find in files within Vim.
" grep for word under cursor in c/cpp/h-files
nnoremap <F9> <Esc>:exec("grep ".expand("<cword>")." ../*/*.c* ../*/*.h")<CR>
You can omit <CR> for manual changing the file pattern before searching.
If you have configured set grepprg=mygrep\ -n then you can use quickfix mode for jumping to the found locations.
TO DO
- Have merged information from other tips to here. See if any more cleaning up is required.
- Confirm that descriptions (drastically simplified wrt help) are accurate.
- Possibly make the "Search in files" section just a line under "See also". Is the 'nnoremap <F9>' stuff useful?