Search
This post extracts some knowledge from Practical Vim Chapter 13 -- Search.
Meet the Search Commands
| Command | Effect |
|---------|--------|
| `n` | Jump to next match, preserving direction and offset |
| `N` | Jump to previous match, preserving direction and offset |
| `/<CR>` | Jump forward to next match of same pattern |
| `?<CR>` | Jump backward to previous match of same pattern |
| `gn` | Enable character-wise Visual mode and select next search match |
| `gN` | Enable character-wise Visual mode and select previous search match |
[!TIP] Highlight Search Matches
:nohlsearch command can be used to mute the search highlighting temporarily.
[!TIP] Preview the First Match Before Execution
| Shortcut | Meaning |
|---|---|
<C-r><C-w> |
Insert the word under the cursor into the command line |
<C-r><C-a> |
Insert the WORD under the cursor into the command line |
* |
Search forward for the word under the cursor |
# |
Search backward for the word under the cursor |
g* |
Search forward for the text under the cursor as a substring (not restricted to whole words) |
g# |
Search backward for the text under the cursor as a substring (not restricted to whole words) |

浙公网安备 33010602011771号