You may have noticed that, when printing your source code using the lpr command from our lab machines, your code seems to run off the end off the paper and "wrap" at the line bellow. You may also have noticed, when editing your code, your code seems to run off the screen. This may be partially due to the size of the tabs used for indenting your code. By default, the size of a tab is 8 characters. You may wish to reduce this unnecessarily large size to either 2 or 4, for example. Here are a couple of remedies:

If you are using vi or vim/gvim, you may enter the following command to reduce the size of your tabs to 4 characters ...
:set tabstop=4

to 2 characters ...
:set tabstop=2

... etc. The tab behavior will reset every time you restart the editor. There are several ways to have this altered permanently. If you are using vim or gvim, type the following line at the command prompt:

echo "set tabstop=4" > ~/.vimrc

If you already have a .vimrc in your home directory (not the default), type the following:

echo "set tabstop=4" >> ~/.vimrc

If you are using vim/gvim, you may also issue the following command to eliminate line wrapping:

:set nowrap

You can also have this altered permanently in a fashion similar to the above.

Unfortunately, when you print the source file, the tabs will remain 8 characters in length. In order to remedy this, when printing your source code, you may use a command similar to the following. Suppose my program is called hello.cc ...

expand -t 4 hello.cc | lpr

This will "expand" the tabs in hello.cc to 4 characters and print the result. The argument 4, of course, is arbitrary and can be set to any size you wish. Alternatively, you may also save the altered file and then print it:

expand -t 4 hello.cc > hello.expanded.cc lpr hello.expanded.cc