Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to search a word from my current cursor position in vim to upward in file.

How to achieve this?

Also how to do same for downward in file.

share|improve this question
1  
You hit the '/' or the '?' keys to look forwards and backwards, respectively. –  galegosimpatico Sep 3 '13 at 10:53
    
The :set hlsearch and :set incsearch commands might be of interest to you. –  evilsoup Sep 3 '13 at 15:22

2 Answers 2

up vote 3 down vote accepted

To search in reverse from your cursor for a word, just use ?. So to find the word "fred" you would issue ?fred.

For forward searching you use /, using "fred" as an example again you would issue /fred.

If you want to continue searching for the same term, in the same direction you can use the n command. (Or you can issue ? or / without arguments).

share|improve this answer

Typing ?search text in command mode searches backward from point while /search text searches forward.

Typing n goes to the next instance of the search text in the direction you were last searching and typing N looks in the opposite direction of your last search.

share|improve this answer
    
Heh snap msw, we said almost the same things! :) –  Drav Sloan Sep 3 '13 at 10:56
2  
Yeah, but I upvoted you first :p –  msw Sep 3 '13 at 10:57
    
I'm just too slow, it must be my age... –  Drav Sloan Sep 3 '13 at 10: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.