Grasping more of the vi editor
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
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?
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
Quick, practical advice for IT pros. Made fresh daily.
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.












