How to Search in Vim Editor

We have heard several times the “Vim” editor tool in Linux distributions. It the most commonly used multiplatform tool that comes up with several modes. Each of its modes has different editing functionality; some are used to perform commands (code editor), and some for the text editor.

It is simple to work with the “Vim” editor but giving more attention to this tool help to learn to explore more.

This guide will focus on the search feature of the “Vim” editor, which is quite handy. We need to understand this because searching for the specific word/string from large file data is not easy.

Let’s start with the “Vim” editor, but keep in mind your mode should be in the command mode.

Getting Started with Vim Editor

Although “Vim” editor is a pre-installed tool in most of the Linux distributions, if you haven’t found it on your machine, execute the given installation command on a terminal:

$ sudo apt install vim

It will be installed on the system (I have already on my system).

Type “vim” or “vi” on the terminal to get an editor on screen:

$ vim

Press “i” to get the insert mode and add any random context from Google to learn the usage of “vim”:

How to Do Search in Vim

The “Vim” editor offers a couple of ways to search for a particular pattern:

  • Forward Searching
  • Backward Searching

Before starting to know about these two ways, keep in mind that you should be careful about case sensitivity as searching in Vim editor is case sensitive.

To avoid this, use the “: set ic,” or an alternative is to use “\c” with the search word for small words and “\C” for capital words.

Forward Searching

Press “Esc” to quit the insert mode and use the forward-slash (/) with the searching word for the quick result.

For example, if looking for the word “Roku”, then type “/roku” in the editor:

Similarly, if looking for a “home”, then use “/home”. As forward-slash (/) represents forward-searching, the editor will highlight the searching word from an upward direction.

One important thing you must know, the search command we are using will look up for the strings like it will highlight the word whether they are the part of another word. To understand this, let’s do an example if type “/where”, the editor will highlight the word “where” from the word “everywhere”:

Another two main functions of Vim editor you should know about:

  • Hit the “n” to move towards the next similar word
  • Hit the “N” to move towards the previous similar word

Backward Searching:

Use the question mark (?) with the particular for backward searching. When do backward searching, the editor will highlight the searching word from a downward direction?

Suppose, if you’re looking for the word Linux, type the “?Linux” in the editor.

The search will start from the last context.

Searching the Whole Word in Vim:

To search for the whole word in Vim, use the following syntax:


(Note that this feature is used to search for the whole word, it doesn’t highlight the particular strings as we have seen in the above section)

Let’s suppose, when you type /\<where\> in the editor, it won’t match with the strings of “everywhere” and highlight it as shown below:

Now, take a look at an authentic example:

If you’re searching for the whole word “secure”, type /\secure<\> in the editor:


In this guide, we have learned how to use the searching feature of the “vim” editor. We have found two ways to search for the particular string or word, i-e forward-searching and backward searching, and check the syntax for the whole word.

The “Vim” is the code and text editor tool having several modes. Each mode is used to perform a specific function. We have used command mode to search for a particular string/word.

About the author

Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.