Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for complete words in vim?

Tags:

vim

If I search for 'string'; I want to find exactly 'string' as a word; and not 'qstring', 'sostring' etc.

Here are the options in my .vimrc

set ic
set showmatch
set smartcase
set incsearch
like image 986
shergill Avatar asked Aug 23 '09 15:08

shergill


People also ask

How do I match a word in Vim?

In normal mode, press / to start a search, then type the pattern ( \<i\> ), then press Enter. If you have an example of the word you want to find on screen, you do not need to enter a search pattern. Simply move the cursor anywhere within the word, then press * to search for the next occurrence of that whole word.

How do I select all text in vi?

To select all in Vim, use ggVG. To go to normal mode, hit the ESC key first. Then, using the gg keys, we'll jump to the beginning of the file. Then, with the V key, enable the visual mode, and last, with the G key, choose from the beginning to the conclusion of the file.


1 Answers

Maybe this regexp will help you: "\<string\>"

like image 141
Michael Foukarakis Avatar answered Nov 03 '22 02:11

Michael Foukarakis