os_dos.txt ForVim version 9.2. Last change: 2026 Feb 14VIM REFERENCE MANUAL by Bram MoolenaardosDOSThis file documents the common particularities of theMS-DOS andWin32versions of Vim. Also seeos_win32.txt andos_msdos.txt.1. File locationsdos-locations2. Using backslashesdos-backslash3. Standard mappingsdos-standard-mappings4. Screen output and colorsdos-colors5. File formatsdos-file-formats6.:cd commanddos-:cd7. Interruptingdos-CTRL-Break8. Temp filesdos-temp-files9. Shell option defaultdos-shell10. PowerShelldos-powershell==============================================================================1. File locationsdos-locationsIf you keep the Vim executable in the directory that contains thehelp andsyntax subdirectories, thereis no need todo anything special for Vim towork. No registry entries or environmentvariables need to be set. Just makesure that the directoryis in your search path, or usea shortcut on thedesktop.Yourvimrc files("_vimrc" and "_gvimrc") are normally located one directoryup from the runtime files. If you want toput them somewhere else, set theenvironment variable$VIM to the directory where you keep them. Example:set VIM=C:\user\pietWill find "c:\user\piet\_vimrc".Note: This would only be needed when the computeris used by several people.Otherwise it's simpler to keep your_vimrc file in the default place.If you move the executable to another location, you also need to set the$VIMenvironment variable. The runtime files will be found in "$VIM/vim{version}".Example:set VIM=E:\vimWill find the version 8.2 runtime files in "e:\vim\vim82".Note: Thisis _not_ recommended. The preferred wayis to keep the executablein the runtime directory.If you move your executable AND want toput your "_vimrc" and "_gvimrc" filessomewhere else, youmust set$VIM to where youvimrc files are, and set$VIMRUNTIME to the runtime files. Example:set VIM=C:\usr\pietset VIMRUNTIME=E:\vim\vim82Will find "c:\user\piet\_vimrc" and the runtime files in "e:\vim\vim82".See$VIM and$VIMRUNTIME for more information.You can set environmentvariables for each user separately through theSystem Propertiesdialog box. The steps todo that:1. Type Windows Key+R to open the "Run"dialog box.2. Enter "sysdm.cpl" and press the "OK" button. The "System Properties"dialog box will open.3.Select the "Advanced"tab and press the "Environment Variables..." button. The "Environment Variables"dialog box will open.4.Select an existing variable in the "Uservariables"list and press the "Edit..." button to edit it. Or press the "New..." button to adda new variable.5. After you finished editing variables, press the "OK" button to save the changes.==============================================================================2. Using backslashesdos-backslashUsing backslashes in file names can bea problem.Vi halves the number ofbackslashes for some commands. Vimisa bit more tolerant and does not removebackslashes froma file name, so ":e c:\foo\bar" worksas expected. But whenabackslash occurs beforea special character (space, comma, backslash, etc.),Vim removes the backslash. Use slashes to avoid problems: ":e c:/foo/bar"works fine. Vim replaces the slashes with backslashes internally to avoidproblems with someMS-DOS programs andWin32 programs.When you prefer to use forward slashes, set the'shellslash' option. Vim willthen replace backslashes with forward slashes when expanding file names. Thisis especially useful when usinga Unix-like'shell'.==============================================================================3. Standard mappingsdos-standard-mappingsThe mappings forCTRL-PageUp andCTRL-PageDown have been removed, they nowjump to the next or previoustab page<C-PageUp><C-PageDown>If you want them to move to the first and last screen line you can use thesemappings:keykey code Normal/Visual mode Insert modeCTRL-PageUp<M-N><M-C-D>H<C-O>HCTRL-PageDown<M-N>v L$<C-O>L<C-O>$Additionally, these keys are available for copy/cut/paste. In theWin32and DJGPP versions, they also use the clipboard.Shift-Insertpaste text (from clipboard)<S-Insert>CTRL-InsertcopyVisual text (to clipboard)<C-Insert>CTRL-DelcutVisual text (to clipboard)<C-Del>Shift-DelcutVisual text (to clipboard)<S-Del>CTRL-XcutVisual text (to clipboard)These mappings accomplish this (Win32 and DJGPP versions of Vim):keykey code NormalVisual InsertShift-Insert<M-N><M-T> "*P"-d"*P<C-R><C-O>*CTRL-Insert<M-N><M-U>"*yShift-Del<M-N><M-W>"*dCTRL-Del<M-N><M-X>"*dCTRL-X<C-X>"*dOr these mappings (non-Win32 version of Vim):keykey code NormalVisual InsertShift-Insert<M-N><M-T>P"-dP<C-R><C-O>"CTRL-Insert<M-N><M-U>yShift-Del<M-N><M-W>dCTRL-Del<M-N><M-X>dWhen theclipboardis supported, the "* registeris used.==============================================================================4. Screen output and colorsdos-colorsThe default outputmethod for the screenis to use bios calls. This worksright away on most systems. Youdo not need ansi.sys. You can use ":mode" toset the current screen mode. See:mode.To change the screen colors that Vim uses, you can use the:highlightcommand. TheNormal highlight groupspecifies the colors Vim uses for normaltext. For example, to get grey text ona blue background::hi Normal ctermbg=Blue ctermfg=greySeehighlight-groups for other groups that are available.ADOS console does not support attributes likebold and underlining. You canset the color used in five modes with nineterminal options.Note that thisis not necessary since you can set the color directly with the ":highlight"command; theseoptions are for backward compatibility with older Vim versions.The'highlight' optionspecifies which of the five modesis used for whichaction.:set t_mr=^V^[\|xxmstart of invert mode:set t_md=^V^[\|xxmstart of bold mode:set t_me=^V^[\|xxmback to normal text:set t_so=^V^[\|xxmstart of standout mode:set t_se=^V^[\|xxmback to normal text:set t_us=^V^[\|xxmstart of underline mode:set t_ue=^V^[\|xxmback to normal text:set t_ZH=^V^[\|xxmstart of italics mode:set t_ZR=^V^[\|xxmback to normal text^VisCTRL-V^[is<Esc>Youmust replace xx witha decimal code, whichis the foreground color numberand background color number added together:COLORFOREGROUNDBACKGROUNDBlack00DarkBlue 1 16DarkGreen 2 32DarkCyan 3 48DarkRed 4 64DarkMagenta 5 80Brown, DarkYellow 6 96LightGray 7 112DarkGray 8 128 *Blue, LightBlue 9 144 *Green, LightGreen 10 160 *Cyan, LightCyan 11 176 *Red, LightRed 12 192 *Magenta, LightMagenta 13 208 *Yellow, LightYellow 14 224 *White 15 240 ** Depending on the display mode, the color codes above 128 may not be available, and code 128 will make the text blink.When you use 0, the coloris reset to the one used when you started Vim(usually 7, lightgray on black, but you can override this. If you haveoverridden the default colors ina command prompt, you may need to adjustsome of the highlight colors in your vimrc---see below).Thisis the default for t_me.The defaults for thevarious highlight modes are:t_mr112 reverse mode: Black text (0) on LightGray (112)t_md 15bold mode: White text (15) on Black (0)t_me0 normal mode (revert to default)t_so 31standout mode: White (15) text on DarkBlue (16)t_se0standout modeend (revert to default)t_ZH225italic mode: DarkBlue text (1) on Yellow (224)t_ZR0italic modeend (revert to default)t_us 67underline mode: DarkCyan text (3) on DarkRed (64)t_ue0underline modeend (revert to default)These colors were chosen because they also look good when using an inverteddisplay, but you can change them to your liking.Example: :set t_mr=^V^[\|97m" start of invert mode: DarkBlue (1) on Brown (96) :set t_md=^V^[\|67m" start of bold mode: DarkCyan (3) on DarkRed (64) :set t_me=^V^[\|112m" back to normal mode: Black (0) on LightGray (112) :set t_so=^V^[\|37m" start of standout mode: DarkMagenta (5) on DarkGreen(32) :set t_se=^V^[\|112m" back to normal mode: Black (0) on LightGray (112)==============================================================================5. File formatsdos-file-formatsIf the'fileformat' optionis set to "dos" (whichis the default), Vim acceptsa single<NL> ora<CR><NL> pair for end-of-line (<EOL>). Whenwritingafile, Vim uses<CR><NL>. Thus, if you edita file and write it, Vim replaces<NL> with<CR><NL>.If the'fileformat' optionis set to "unix", Vim usesa single<NL> for<EOL>and shows<CR>as ^M.You can use Vim to replace<NL> with<CR><NL> by reading in any mode andwriting in Dos mode(":se ff=dos").You can use Vim to replace<CR><NL> with<NL> by reading in Dos mode andwriting inUnix mode(":se ff=unix").Vim sets'fileformat' automatically when'fileformats'is not empty (whichisthe default), so you don't really have to worry about what you are doing.If you want to editascript file ora binary file, you should set the'binary' option before loading the file. Script files and binary files maycontain single<NL> characters which Vim would replace with<CR><NL>. You canset'binary' automatically bystarting Vim with the "-b" (binary) option.==============================================================================6.:cd commanddos-:cdThe ":cd" command recognizes the drive specifier and changes the currentdrive. Use ":cd c:" to make driveC the active drive. Use ":cd d:\foo" togoto the directory "foo" in the root of drive D. Vim also recognizes UNC namesif the system supports them; e.g., ":cd \\server\share\dir".:cd==============================================================================7. Interruptingdos-CTRL-BreakUseCTRL-Break instead ofCTRL-C to interrupt searches. Vim does not detecttheCTRL-C untilit tries to reada key.==============================================================================8. Temp filesdos-temp-filesOnly for the 16 bit and 32 bitDOS version:Vim puts temporary files (for filtering) in the first of these directoriesthat exists and in which Vim can createa file:$TMP$TEMPC:\TMPC:\TEMPcurrent directoryFor theWin32 version (both console and GUI):Vim uses standard Windowsfunctions to obtaina temporary file name (forfiltering). The first of these directories that exists and in which Vim cancreatea fileis used:$TMP$TEMPcurrent directory==============================================================================9. Shell option defaultdos-shellThe default for the'sh' ('shell') optionis "command.com" on Windows 95 and"cmd.exe" on Windows NT. IfSHELLis defined, Vim usesSHELL instead, and ifSHELLis not defined butCOMSPEC is, Vim uses COMSPEC. Vim starts externalcommands with "<shell> /c<command_name>". TypingCTRL-Z startsa new commandsubshell. Return to Vim with "exit".'shell'CTRL-ZIf you are runninga third-party shell, you may need to set the'shellcmdflag' ('shcf') and'shellquote' ('shq') or'shellxquote'('sxq') options. Unfortunately, this also depends on the version of Vim used.For example, with the MKS Korn shell or with bash, the values of theoptionsshould be:DOS 16 bit DOS 32 bitWin32'shellcmdflag'-c-c-c'shellquote' "'shellxquote' "For Dos 16 bit this starts the shell as:<shell> -c "command name" >fileForWin32 as:<shell> -c "command name >file"ForDOS 32 bit, DJGPP does this internally somehow.Whenstarting up, if Vim does not recognisea standard Windows shellit checksfor the presence of "sh" anywhere in the'shell' option. Ifitis present,Vim sets the'shellcmdflag' and'shellquote' or'shellxquote'options will besetas described above.==============================================================================10. PowerShelldos-powershelldos-pwshVim supports PowerShell Desktop and PowerShell Core. PowerShell Desktopisthe version of PowerShell thatis installed with Windows, while PowerShellCoreisa separate downloadable version that works cross-platform. To seewhich version you are using then enter the following ina PowerShell prompt-$PSVersionTable.PSEditionIf'shell' includes "powershell" in the filenameatstartup then VIM sets'shellcmdflag','shellxquote','shellpipe', and'shellredir'options to thefollowing values:'shellcmdflag'-Command'shellxquote'"'shellpipe'2>&1 | Out-File -Encoding default'shellredir'2>&1 | Out-File -Encoding defaultIf'shell' includes "pwsh" in the filenameatstartup then VIM sets'shellcmdflag','shellxquote','shellpipe', and'shellredir'options to thefollowing values:'shellcmdflag'-c'shellxquote'"'shellpipe'>%s 2>&1'shellredir'>%s 2>&1Note: thoseoptions are only set after reading the.vimrc file, inparticular setting the'shell' option via-cis too late to take effect forthe other shell related settings. Consider using--cmd to override thisoption via the command line.If you find that PowerShell commands are takinga long time to run then trywith "-NoProfile"at the beginning of the'shellcmdflag'.Note this willprevent any PowerShell environment setup by theprofile from taking place.If you have problems running PowerShell scripts through the'shell' then trywith "-ExecutionPolicy RemoteSigned -Command"at the beginning of'shellcmdflag'. See online Windows documentation for more information onPowerShell Execution Policy settings.Seeoption-backslash about including spaces in'shellcmdflag' when usingmultiple flags.The'shellpipe' and'shellredir' option values re-encode the UTF-16LE outputfrom PowerShell Desktop to your currently configured console codepage. Theoutput can be forced intoa different encoding bychanging "default" to one ofthe following:unicode- UTF-16LE (default output from PowerShell 5.1)bigendianunicode- UTF-16utf8-UTF-8utf7- UTF-7 (no BOM)utf32- UTF-32ascii- 7-bit ASCII character setdefault- System's active code page (typically ANSI)oem- System's current OEM code pageNote The abovemulti-byteUnicode encodings includea leading BOM unlessotherwise indicated.By default PowerShell Core's outputisUTF-8 encoded withouta BOM. If youwant to force the output of PowerShell Core intoa different encoding then set'shellredir' and'shellpipe' to "2>&1 | Out-File -Encoding encoding" whereencodingis one of the following:ascii- 7-bit ASCII character setbigendianunicode- UTF-16BEbigendianutf32- UTF-32BEoem- System's current OEM code pageunicode- UTF-16LEutf7- UTF-7utf8-UTF-8utf8BOM- UTF-8, with BOMutf8NoBOM- UTF-8, no BOM (default output from PowerShell Core)utf32- UTF-32Since PowerShell Core 6.2, the Encoding parameter also supports specifyinganumeric ID ofa registered code page (-Encoding 1251) orstring names ofregistered code pages (-Encoding "windows-1251"). The .NET documentation forEncoding.CodePage has more information vim:tw=78:ts=8:noet:ft=help:norl: