Vi editor

Hello Linux/Unix experts,

I have an application based off FREEBSD.
Using the VI editor, I open up a text document.

how do i

1) Page all the way to the top of the document and page all the way to the bottom of the document

2) search for keyword TEST
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
See comments above by farzanj - easiest IMHO are:


(no command mode needed)

After searching once for /TEST - use n to find again (in same direction). To change direction (with same pattern) use ? and then n again to find again (the other direction).
farzanjConnect With a Mentor Commented:
Go to the command mode by pressing Esc key

To go to the top


For bottom of document


To search test in command mode


and hit enter
Another way to navigate is to go to command mode by pressing Esc and do

To go to line number 1
Or you can give any line number

And for last line you can use $

In search some people use :/TEST

But : is really not needed.

To go to next TEST forward, use n
To go to next TEST backward, use N
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

serialbandConnect With a Mentor Commented:
Some other useful navigation controls.
Control+D pages down half a page at a time
Control+U pages up half a page at a time
Control+F pages down a full page at a time
Control+B pages up a page at a time

Here's a web page with the command list for vi.
What?  No one added anything to my answer which was accurate and a day earlier.  One expert answer was not even addressing the question.  Second one repeated pretty much what I said earlier, just gave fewer options.
Gerwin Jansen, EE MVETopic Advisor Commented:
@trojan81 - I agree with farzanj - you could have split a bit differently in this case, I added the search direction options though that are useful.
Thank you Gerwinjansen.  I had the direction included too.  You see you can simply do it with /SEARCH and then you want to go forward you press 'n' and for backwards you press 'N'.
/SEARCH and ?SEARCH is just another way to do the same.
I didn't bother addressing the direct question, because you had already addressed it.  I decided to add additional value by providing additional navigation instructions as well as include a link with more vi commands.

Are you getting paid based on points?  I've lost out on many points this same way.  It's just points, it happens, not a big deal.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.