Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Vi editor

Posted on 2013-06-14
8
Medium Priority
?
376 Views
Last Modified: 2016-02-11
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
0
Comment
Question by:trojan81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 532 total points
ID: 39249179
Go to the command mode by pressing Esc key

To go to the top
Do
gg

Or
1G

For bottom of document

Press
G


To search test in command mode

/TEST

and hit enter
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39249186
Another way to navigate is to go to command mode by pressing Esc and do
:1

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
0
 
LVL 30

Assisted Solution

by:serialband
serialband earned 532 total points
ID: 39249551
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.

http://www.cs.rit.edu/~cslab/vi.html
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 536 total points
ID: 39250109
See comments above by farzanj - easiest IMHO are:

gg
G
/TEST

(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).
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39252869
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.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 39253839
@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.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39253847
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.
0
 
LVL 30

Expert Comment

by:serialband
ID: 39254271
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.
0

Featured Post

Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question