Grasping more of the vi editor

on this topic
October 2, 2001, 03:22 PM —  ITworld.com — 

The response to part 1 of our introduction to
vi (the first Unix101 column) was terrific. I'm glad that so many of
you liked the article. There were a lot of great suggestions -- some of
which are included in this article, and some of which I will
save up for when we revisit vi in a future column.

This article covers manipulating vi's default behavior and
cutting and pasting within as well as across files.
Customizing vi's behavior and learning to manage its buffers
can greatly improve its performance.

Vi's search function is a prime example of this. Searching is done
from command mode by typing a slash followed by the search text as in:


/Encyclopedia

This will search for the string Encyclopedia. Once an "Encyclopedia" is
found, typing an "n" will search for the next "Encyclopedia." Having
grown accustomed to PC editors that tend to default to a
case-independent search, vi annoyed me with the fact that /Encyclopedia
would find "Encyclopedia" but not "encyclopedia" or "ENCYCLOPEDIA." Vi
has a setting that will cause the search to ignore case. This is an ex
mode command, so from command mode you type it as a colon followed by
ic as in:


:set ic      (and press RETURN)

Ic is shorthand for ignorecase. If you need to turn this off
for a case-dependent search, type:


:set noic    (and press RETURN)

Another useful set option is showmode. If you tend to type
and then break for something (research or a fresh coffee), you might
walk away from the computer leaving vi in insert or edit mode.


:set showmode

will place a message in the last line of the screen on the
right indicating that you are in INSERT MODE, APPEND MODE, or
whatever.

This can be turned off with


:set noshowmode

To turn line numbering on and off use:


:set number

and


:set nonumber

Numbers are displayed at the beginning of
each line. These numbers do not appear in the document, simply on the
screen. They can be helpful if you are trying to compose something that
must fit in 55 lines (for a printed page).

Wrapping text

Setting the wrap margin will cause the text to auto wrap while you
are typing, but the command is quirky in a vi-ish sort of way. The
command is

Sign up for ITworld's Daily newsletter
Follow ITworld on Twitter @IT_world

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
peer-to-peer

Esther Schindler
If the comments are ugly, the code is ugly

claird
SVG a graphics format for 21st century

pasmith
Take Chrome OS for a test spin

Sandra Henry-Stocker
Solaris Tip: Have Your Files Changed Since Installation?

sjvn
64-bits of protection?

jfruh
Android fragments vs. the iPhone monolith

mikelgan
What Gizmodo missed about the Pro WX Wireless USB disk drive

 

Sidekick: The Good News & the Bad News
Either way you look at it Microsoft Data Center management did not follow standards or best practices in this failure. In which case it makes me wonder more about the outsourcing of corporate data much less personal data.
- mburton325

Join the conversation here

The Daily Tip

The Daily TipQuick, practical advice for IT pros. Made fresh daily.

Hot tips:

Want to cash in on your IT savvy? Send your tip to tips@itworld.com. If we post it, we'll send you a $25 Amazon e-gift card.

Newsletters

Subscribe to ITWORLD TODAY and receive the latest IT news and analysis.

I would like to receive offers via email from ITworld partners.
By clicking submit you agree to the terms and conditions outlined in ITworld's privacy policy.
Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

Marketplace