Java Reference
In-Depth Information
affected by this setting. The default for vi is noignorecase , which means case
is significant.
The autoindent setting (can be abbreviated ai ) means that when you do
an o or O to open a line after or before ( o versus O ) the line on which your cursor
rests, vi will automatically add whitespace so that the text that you enter begins
at the same column where the current line begins.
For example, suppose you are editing an if statement like this:
if (userBalance < minDaily) {
userAccount.chargeFees();
}
With your cursor on the middle line, if you type an o or O , the new (blank)
line will open with your cursor at the fifth character position, right in line with
the “u” of userAccount . If you find that your cursor is flush left when you try
this, then you need to set autoindent. You can do this from within vi by typing
:set ai or the longer :set autoindent . The leading “ : ” is important—it
gets you to ex mode. (Don't forget to press Enter at the end of the command.)
The shiftwidth setting tells vi how many character positions to move
text left or right with each << (left) or >> (right) command, as well as when
typing ^D and ^T in input mode. When typing text in input mode, people often
use the Tab key to indent their text, for example inside an if or for statement.
You can do this in vi , and the actual tab character will be the character in your
text. But if you want tighter indenting, use the ^T (that's Control-T, “T” for
Tab, we suppose) to increase your indent and ^D to decrease your indent while
in input mode. The vi editor will automatically compute how much whitespace
to use and will put an optimal combination of tabs and spaces as needed to line
things up. Alternately, you can have vi always expand tabs into spaces and not
mix tabs and spaces, but just use spaces, with set expandtab . (Remember to
add a “ : ” if you want to type this from the command line.)
2.3
E DITORS G ALORE
There are many editors available to a programmer on a Linux system. Some are
text-based editors, typically antedating GUI interfaces. Many have graphical
interfaces, with mouse-based cut and paste and the like. We will mention sev-
eral here and encourage you to find the one with which you are comfortable.
Search WWH ::




Custom Search