If you search something in Vim by prepending searchterm with a forward slash, e.g. /searchterm, Vim puts that searchterm into the search string history table. You then are able to navigate through past search terms by typing in forward slash (/) and using Up/Down arrow keys.

That search string history table is persistent across Vim restarts.

Everything above is also true for command (typed with : prepended) history table.

How do I clear those history tables?

1 Answer 1


The history is persisted in the viminfo file; you can configure what (and how many of them) is persisted via the 'viminfo' (and 'history') options.

You can clear the history via the histdel() function, e.g. for searches:

:call histdel('/')

You can even delete just certain history ranges or matching lines.

Alternatively, you could also just edit the ~/.viminfo file directly (when Vim is closed, and either with another editor, or with vim -i NONE).

  • 1
    :call histdel(":") deletes the entire command history. Use :call histdel(":", "expr") to delete entries matching an expression. Oct 18, 2020 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.