Vim Recall繁體中文

Reuse a complex search pattern

q/

Example

Normal mode. Most recent search: status=failed. Buffer contains status=pending.

Before
Search history: status=failed Wanted match: status=pending

  1. q/ Search history opens · cursor on the final blank row
  2. k$ciwpending<Esc> Select the previous search and edit it · status=pending
  3. <CR> Jump to status=pending · buffer unchanged

After
Search run: status=pending Cursor: at a matching location Buffer text: unchanged

Details & Vim help

Open forward-search history in an editable window.

Refine a complex pattern without rebuilding it at the search prompt.

q? opens backward-search history. The search window is unavailable while recording a macro, and search options still affect the selected pattern.

Editing a search changes what you look for; it does not replace buffer text.

Try it in Vim

  1. Type q/ in Normal mode.
  2. Find a previous pattern and edit its line.
  3. Press <CR> to search with that line; close with :q<CR> to cancel.