Search for Strings and Highlight Syntax in the Vim Text Editor

In this article I will show you how to use the search option in the Vim text editor and some settings for syntax highlighting.

To use the Vim search, press ESC, type /string . (replace string with the keyword you want to find)

In this screen I search for the geek string: /geek

http://linuxg.net/wp-content/uploads/2013/01/print1.png

To enable syntax highlighting, press ESC and type :set hlsearch.

print2

By default, the search is case sensitive in vim. To make the search case insensitive, pres ESC and type :set ignorecase.

Another way, without using :set ignorecase, is to type \c in the search, like this: /string\c . This will match string, String, StRinG, and any other string combination, with low and upper cases.

print3

To disable the syntax highlighting, press ESC and type :set nohlsearch.

By pressing ESC, you quit from whatever mode you are, and switch to the command mode. It is useless to set configurations in any other mode than the command mode.

Share and Enjoy

  • Twitter
  • Facebook
  • Google Plus
  • Email
  • RSS
Tagged with: , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!