Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

vimtutor says this in lesson 4.2 : The search command

  1. In Normal mode type the / character. Notice that it and the cursor appear at the bottom of the screen as with the : command.

    1. Now type 'errroor' . This is the word you want to search for.

    2. To search for the same phrase again, simply type n . To search for the same phrase in the opposite direction, type N .

This works perfectly while practicing with the vim tutor but I can't seem to get it to work with a file .basically when I type the / character and then key in the pattern to search , it is going to the first match as expected . But below the contents of the file I still see my search pattern with a blinking cursor . For example if I my pattern was the string foo , I see /foo and the cursor keeps blinking . Then pressing n just appends the the pressed character to the search string and the search pattern now becomes /foon which is not what I want .

Why am I seeing this issue and how can I fix this ?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You need to conclude the search by pressing Enter. You're back in normal mode, where the n / N commands apply. As you may have noticed, Vim is a modal editor (best seen in that you need to press i to insert characters).

Vim appears to jump to the search pattern while you're typing it, but that's just a preview by the 'incsearch' feature.

share|improve this answer

pressing n just appends the the pressed character to the search string and the search pattern now becomes /foon

vim is modal, it has command mode (where n means next match) and it has insert mode (where n means insert the character "n".)

It may be that you are using a special setup of vim, such as cream, that attempts to make vim act like a simple non-modal editor.

If you are using an unmodified vim with no unusual plugins or settings, press Esc to exit insert-mode. The status line usually displays "INSERT" when in insert mode (but you can configure it not to - so check for this)


Update here's what you can expect to see in two different versions of Vim on two different platforms

Platform 1 - note status info is in reverse and includes flilename and an indicator that a change has been made ([+])

1) After opening a file and typing /hath

enter image description here

2) After pressing i

enter image description here

Platform 2 - note that all onscreen matches are highlighted.

1) After opening a file and typing /hath

enter image description here

2) After pressing i

enter image description here

Some aspects of Vim's appearance depend on version and configuration.

use :ve to display version of vim. It may help potential answerers for you to amend your question and include this information together with the name and version of operating system.

share|improve this answer
    
I tried this but it doesn't work. The status line is not displaying "INSERT" but all i see is /foo and then a blinking cursor . And on pressing <kbd>Esc</kbd> I see the line number,column number and a percentage like 19% at the extreme right. –  Geek Jan 28 '13 at 15:33
    
Next if I press "n" , I see E:486 Pattern Not found :errroor . This string "errroor" incidentally the pattern that I practiced in vimtutor –  Geek Jan 28 '13 at 15:39
    
when you press the "i" key to enter insert-mode, does it display "--INSERT --" on the line below the status line? –  RedGrittyBrick Jan 28 '13 at 15:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.