zhuang@linux:~/reading/practical-vim/13-search/$ less
Search
This post extracts some knowledge from Practical Vim Chapter 13 – Search.
Meet the Search Commands
markdown
| 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 |:nohlsearch command can be used to mute the search highlighting temporarily.
| 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) |
/lang/e<CR> places the cursor at the end of the search match.
If original search starts from the head of search match, then use //e<CR> to switch to the end of search match.
If we can arrange things such that pressing the . command jumps to the next match and applies the last operation, then we can use one keystroke to repeat each change. I call this the Improved Dot Formula.
zhuang@linux:~/reading/practical-vim/13-search/$ comments