home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.34 vi Line Commands vs. Character Commands Chapter 30
vi Tips and Tricks
Next: 30.36 The ex Open Mode Can Be Handy
 

30.35 Out of Temporary Space? Use Another Directory

vi keeps its temporary copy of the file you're editing in a temporary-file directory ( 21.2 ) - usually /tmp , /usr/tmp , or /var/tmp . If you're editing a big file or if the temporary filesystem runs out of space, vi may not be able to make your temporary file. When that happens, you can use vi 's set directory command to set the pathname of a different temporary directory. (If this happens a lot though, you should talk to the system administrator and see if the standard area can be cleaned up or made bigger.)

First, you'll need the absolute pathname ( 14.2 ) of a directory on a filesystem with enough room ( 24.9 ) . Use an existing directory or make a new one.

The vi command is set directory - for example,

set directory=/usr1/jim/vitemp

You have to type that command before giving vi a filename to edit - after that, vi has made the temporary file and you'll be too late. But if you type that command while using vi and then use the :e command ( 30.4 ) , all files from then on will use the new temporary directory.

To set the directory temporarily, it's probably easiest to add that command to the EXINIT environment variable ( 6.1 ) :

setenv EXINIT 'set directory=/usr1/jim/vitemp'

There are other ways to change EXINIT , too - see article 6.10 .

If you already have a .exrc file ( 30.6 ) , setting EXINIT will make vi ignore your .exrc file. To make the temporary set directory work, too, use a command with a vertical bar ( | ) like this:

setenv EXINIT 'source /usr1/jim/.exrc|set directory=/usr1/jim/vitemp'

- JP


Previous: 30.34 vi Line Commands vs. Character Commands UNIX Power Tools Next: 30.36 The ex Open Mode Can Be Handy
30.34 vi Line Commands vs. Character Commands Book Index 30.36 The ex Open Mode Can Be Handy

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System