
Searching in Vim
Overview
As a developer, two major challenges when transitioning to Vim from other editors/IDEs are figuring out how to search for a file or content. Even after using Vim for a while, you might forget these commands if not used frequently.
This documentation aims to provide a clear guide on how to search in Vim.
Search for a file
In Vim, this is commonly referred to as fuzzy find
.
Configuration:
set path+=**
set wildmenu
For example, to locate a README file in a repo:
:find README
Pressing the Tab key will trigger a menu showing all possible files.
Search for Occurrence
The :vim
command is a shorthand for the :vimgrep
command,
and it is preferred for simplicity.
For example, to look for PY_VERSION
keyword in cpython
repo:
:vim /PY_VERSION/g */*.h
This command will search for PY_VERSION
in all .h
files
in the current directory and its subdirectories.
Feel free to expand on these examples and configurations as you become more comfortable with Vim’s search functionalities.