Vim Tips Wiki

Fix errors that relate to reading or creating files in the temp or tmp environment on an MS Windows PC

1,610pages on
this wiki
Revision as of 18:26, March 7, 2013 by Fritzophrenic (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 1532 Printable Monobook Previous Next

created November 13, 2007 · complexity basic · author corp-mule · version 7.0

This tip will help resolve error messages E97, E483, E484, E485, and E810 encountered on machines running MS Windows. These errors relate to the creation of, or reading of temporary files. See :help E97, :help E483, :help E485. Also see Fix error E97 Cannot create diffs under Windows.

*e97* Can't create diffs blah blah
*e485* Can't read file blah blah

I've experienced these errors when trying to use the diff commands, or any shell commands being called via the :! or :r! commands.

That is,

:r! sort blah blah blah %
:r! dir

Generic causesEdit

To correct this problem you may need to change your environment variable for $TMP or $TEMP, to somewhere you have write access. You can do this in a couple of different ways.

1. Use the Windows environment settings. Here is one method.
    - Right click "My Computer".
    - Choose "Properties".
    - Click the "Advanced" tab.
    - Click the "Environment Variables" button.
    - In the bottom window pane, scroll down to the TMP or
      TEMP variables and highlight them.
    - Then click the "Edit" button and change the path to
      the directory you want.
2. Use Vim – much better!
    - Add the following to your _vimrc file:
      let $TMP="c:/tmp"

In both cases, you need to create the directory (for example, C:\tmp), and you need read and write permission in that directory.

Another possible cause, as mentioned at :help E484 starting with Vim 7.3.845, is bad escaping of shell commands. If you have any special characters in an external command, such as any of the characters ^&|<>() or space characters, you will probably need to escape them with the shellescape() function before passing them to an external command.


A common cause for the specific E303 error on recent versions of Windows, is that Microsoft at some point moved the default value of %TEMP% and %TMP% to reside somewhere deep within the current user's home directory, and removed the previous default directory C:\Temp and C:\TMP. For some reason, Vim doesn't (as of 2013-03-07) use $TEMP or $TMP for the default value of the 'directory' option. Fixing this is easy, just put this in your .vimrc:

set directory=.,$TMP,$TEMP

See for current status of this issue.



  • This tip needs reworking. A reader could get the impression that the only cause for the specified errors is due to TMP.
  • Add a brief explanation of what the environment variables do.
  • Probably want reference to :help dos-temp-files. Any others?
  • The title is not helpful because a reader would only search for this title if they already knew the cause of their problem.
Advertisement | Your ad here

Around Wikia's network

Random Wiki