What is MIME type "text/x-vim"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The MIME type text/x-vim marks Vim script files. They contain VimL code used by the Vim text editor.
It tells software which rules to use when displaying and editing these scripts.
Files like VIM, EXRC, GVIMRC, and VIMRC run settings or commands when Vim starts.
For more on Vim scripting, visit the Vim official website.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/x-vim    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/x-vim">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/x-vim');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

How do I configure Apache to serve .vim files correctly?

To serve Vim scripts with the correct MIME type, add the AddType directive to your .htaccess file or main configuration. Use the line: AddType text/x-vim .vim .vimrc .gvimrc. This ensures browsers and clients identify the file content as VimL code rather than generic text.

Why does the MIME type text/x-vim start with "x-"?

The x- prefix indicates that this is a non-standard or experimental MIME type not officially registered with the IANA. While common among developers, it is a convention used to identify VIM scripts and configuration files before a standard type is adopted.

Can web browsers execute text/x-vim files?

No, web browsers cannot execute Vim scripts. When a browser encounters a file sent as text/x-vim, it will typically display it as plain text or prompt the user to download it. To run the code, the file must be opened in the Vim or Neovim text editor.

How do I add text/x-vim support to Nginx?

You can add the mapping to your mime.types file or directly inside a server block. Add the line text/x-vim vim vimrc; to ensure Nginx sends the correct Content-Type header for files with the .vim or .vimrc extensions.

Is it safe to open text/x-vim files?

Generally, yes, as they are plain text files. However, because they contain executable commands for the Vim editor, you should treat unknown VIMRC or script files with caution. Always inspect the code before loading it into your editor to prevent malicious commands from running.

What is the difference between text/x-vim and text/plain?

While both types represent human-readable text, text/x-vim specifically denotes that the content is Vim Script. Using the specific MIME type helps operating systems and editors trigger appropriate features, such as syntax highlighting for VimL, which wouldn't happen automatically with generic text/plain.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.