Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»How to Search in Vim / Vi

    How to Search in Vim / Vi

    RahulBy RahulFebruary 16, 20212 Mins Read

    vi (visual editor) is the best command line text file editor for Unix-like operating systems. Vim is an improved version of the vi text editor used on modern systems. This is a highly configurable text editor.

    This tutorial will help you search for text, string or pattern in Vi(m) text editor.

    How to Search in Vi(m) Editor

    To start searching in the Vi(m) editor, first press the ESC key to switch to command mode in the editor. Then press “/” and then press the search text.

    1. Press ESC
    2. Type “/”
    3. Type the search pattern
    4. Press Enter or Return key perform search
    /pattern
    

    How to search in Vim

    This will move the cursor to the first match of the searched string. Then use the shortcut keys to navigate to the previous or next search string, as shown below:

    • Press n (in small letter) to search for next occurrences
    • Press N (in capital letter) to search for previous occurrences

    Case Insensitive Search in Vim

    Default vim searches for case sensitive matches. To search for pattern in all cases, you need to disable case using set command in vim.

    Type the following command in vim to disable case sensitive searches.

    :set ignorecase
    

    Search vim with ignore case (case insensitive search)

    Next, again do search for some text, you will find that search selection is ignoring the case.

    You can revert the above changes by using noignorecase with set command.

    :set noignorecase
    

    Now, vim will again do the case sensitive searches.

    Search Whole World Only

    You can also search for pattern matches whole world only. Which means the search do not matches substring of string.

    /\<pattern\>
    

    View Search History

    Vim keeps all the search history performed in current session. To view the previous searches, press / and use up and down keys

    Conclusion

    In this tutorial, you have learned about searching in vim/vi text editor in Linux command line.

    vi vim
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install PHP 8 on CentOS/RHEL 8
    Next Article How To Install PHP 8 on Debian 10

    Related Posts

    How To Install Docker on Ubuntu 22.04

    3 Mins Read

    Filesystem Hierarchy Structure (FHS) in Linux

    Updated:July 1, 20222 Mins Read

    What is CPU? – Definition, Types and Parts

    3 Mins Read

    How to Install Ionic Framework on Ubuntu 22.04

    3 Mins Read

    What is the /etc/hosts file in Linux

    Updated:June 27, 20222 Mins Read

    Creating DMARC Record for Your Domain

    Updated:June 29, 20223 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.