Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2001 · complexity basic · author Yegappan · version 5.7
To display the definition of a variable, place the cursor on the variable and use the
To display a macro definition, place the cursor on the macro name and use the
To display all the lines containing the variable name under the cursor, use the
These commands work by literally searching for the text. So they work in most, but not all, cases.
- 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
- Jump to first match (first line in file containing keyword).
- Ctrl-i is Tab, so,
[<Tab>also jumps to the first match.
- 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.
- Go to definition of local variable (first occurrence of keyword in current function).
- Go to definition of global variable (first occurrence of keyword in current file).
- List lines with keyword and prompt for jump
- List lines with current search pattern highlighted
- Search visually
Search in filesEdit
: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.
- 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?