os_dos.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. *os_dos.txt* For Vim version 9.0. Last change: 2006 Mar 30
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. *dos* *DOS*
  4. This file documents the common particularities of the MS-DOS and Win32
  5. versions of Vim. Also see |os_win32.txt| and |os_msdos.txt|.
  6. 1. File locations |dos-locations|
  7. 2. Using backslashes |dos-backslash|
  8. 3. Standard mappings |dos-standard-mappings|
  9. 4. Screen output and colors |dos-colors|
  10. 5. File formats |dos-file-formats|
  11. 6. :cd command |dos-:cd|
  12. 7. Interrupting |dos-CTRL-Break|
  13. 8. Temp files |dos-temp-files|
  14. 9. Shell option default |dos-shell|
  15. 10. PowerShell |dos-powershell|
  16. ==============================================================================
  17. 1. File locations *dos-locations*
  18. If you keep the Vim executable in the directory that contains the help and
  19. syntax subdirectories, there is no need to do anything special for Vim to
  20. work. No registry entries or environment variables need to be set. Just make
  21. sure that the directory is in your search path, or use a shortcut on the
  22. desktop.
  23. Your vimrc files ("_vimrc" and "_gvimrc") are normally located one directory
  24. up from the runtime files. If you want to put them somewhere else, set the
  25. environment variable $VIM to the directory where you keep them. Example: >
  26. set VIM=C:\user\piet
  27. Will find "c:\user\piet\_vimrc".
  28. Note: This would only be needed when the computer is used by several people.
  29. Otherwise it's simpler to keep your _vimrc file in the default place.
  30. If you move the executable to another location, you also need to set the $VIM
  31. environment variable. The runtime files will be found in "$VIM/vim{version}".
  32. Example: >
  33. set VIM=E:\vim
  34. Will find the version 8.2 runtime files in "e:\vim\vim82".
  35. Note: This is _not_ recommended. The preferred way is to keep the executable
  36. in the runtime directory.
  37. If you move your executable AND want to put your "_vimrc" and "_gvimrc" files
  38. somewhere else, you must set $VIM to where you vimrc files are, and set
  39. $VIMRUNTIME to the runtime files. Example: >
  40. set VIM=C:\usr\piet
  41. set VIMRUNTIME=E:\vim\vim82
  42. Will find "c:\user\piet\_vimrc" and the runtime files in "e:\vim\vim82".
  43. See |$VIM| and |$VIMRUNTIME| for more information.
  44. You can set environment variables for each user separately through the
  45. System Properties dialog box. The steps to do that:
  46. 1. Type Windows Key + R to open the "Run" dialog box.
  47. 2. Enter "sysdm.cpl" and press the "OK" button. The "System Properties"
  48. dialog box will open.
  49. 3. Select the "Advanced" tab and press the "Environment Variables..." button.
  50. The "Environment Variables" dialog box will open.
  51. 4. Select an existing variable in the "User variables" list and press the
  52. "Edit..." button to edit it. Or press the "New..." button to add a new
  53. variable.
  54. 5. After you finished editing variables, press the "OK" button to save the
  55. changes.
  56. ==============================================================================
  57. 2. Using backslashes *dos-backslash*
  58. Using backslashes in file names can be a problem. Vi halves the number of
  59. backslashes for some commands. Vim is a bit more tolerant and does not remove
  60. backslashes from a file name, so ":e c:\foo\bar" works as expected. But when
  61. a backslash occurs before a special character (space, comma, backslash, etc.),
  62. Vim removes the backslash. Use slashes to avoid problems: ":e c:/foo/bar"
  63. works fine. Vim replaces the slashes with backslashes internally to avoid
  64. problems with some MS-DOS programs and Win32 programs.
  65. When you prefer to use forward slashes, set the 'shellslash' option. Vim will
  66. then replace backslashes with forward slashes when expanding file names. This
  67. is especially useful when using a Unix-like 'shell'.
  68. ==============================================================================
  69. 3. Standard mappings *dos-standard-mappings*
  70. The mappings for CTRL-PageUp and CTRL-PageDown have been removed, they now
  71. jump to the next or previous tab page |<C-PageUp>| |<C-PageDown>|
  72. If you want them to move to the first and last screen line you can use these
  73. mappings:
  74. key key code Normal/Visual mode Insert mode ~
  75. CTRL-PageUp <M-N><M-C-D> H <C-O>H
  76. CTRL-PageDown <M-N>v L$ <C-O>L<C-O>$
  77. Additionally, these keys are available for copy/cut/paste. In the Win32
  78. and DJGPP versions, they also use the clipboard.
  79. Shift-Insert paste text (from clipboard) *<S-Insert>*
  80. CTRL-Insert copy Visual text (to clipboard) *<C-Insert>*
  81. CTRL-Del cut Visual text (to clipboard) *<C-Del>*
  82. Shift-Del cut Visual text (to clipboard) *<S-Del>*
  83. CTRL-X cut Visual text (to clipboard)
  84. These mappings accomplish this (Win32 and DJGPP versions of Vim):
  85. key key code Normal Visual Insert ~
  86. Shift-Insert <M-N><M-T> "*P "-d"*P <C-R><C-O>*
  87. CTRL-Insert <M-N><M-U> "*y
  88. Shift-Del <M-N><M-W> "*d
  89. CTRL-Del <M-N><M-X> "*d
  90. CTRL-X <C-X> "*d
  91. Or these mappings (non-Win32 version of Vim):
  92. key key code Normal Visual Insert ~
  93. Shift-Insert <M-N><M-T> P "-dP <C-R><C-O>"
  94. CTRL-Insert <M-N><M-U> y
  95. Shift-Del <M-N><M-W> d
  96. CTRL-Del <M-N><M-X> d
  97. When the clipboard is supported, the "* register is used.
  98. ==============================================================================
  99. 4. Screen output and colors *dos-colors*
  100. The default output method for the screen is to use bios calls. This works
  101. right away on most systems. You do not need ansi.sys. You can use ":mode" to
  102. set the current screen mode. See |:mode|.
  103. To change the screen colors that Vim uses, you can use the |:highlight|
  104. command. The Normal highlight group specifies the colors Vim uses for normal
  105. text. For example, to get grey text on a blue background: >
  106. :hi Normal ctermbg=Blue ctermfg=grey
  107. See |highlight-groups| for other groups that are available.
  108. A DOS console does not support attributes like bold and underlining. You can
  109. set the color used in five modes with nine terminal options. Note that this
  110. is not necessary since you can set the color directly with the ":highlight"
  111. command; these options are for backward compatibility with older Vim versions.
  112. The |'highlight'| option specifies which of the five modes is used for which
  113. action. >
  114. :set t_mr=^V^[\|xxm start of invert mode
  115. :set t_md=^V^[\|xxm start of bold mode
  116. :set t_me=^V^[\|xxm back to normal text
  117. :set t_so=^V^[\|xxm start of standout mode
  118. :set t_se=^V^[\|xxm back to normal text
  119. :set t_us=^V^[\|xxm start of underline mode
  120. :set t_ue=^V^[\|xxm back to normal text
  121. :set t_ZH=^V^[\|xxm start of italics mode
  122. :set t_ZR=^V^[\|xxm back to normal text
  123. ^V is CTRL-V
  124. ^[ is <Esc>
  125. You must replace xx with a decimal code, which is the foreground color number
  126. and background color number added together:
  127. COLOR FOREGROUND BACKGROUND ~
  128. Black 0 0
  129. DarkBlue 1 16
  130. DarkGreen 2 32
  131. DarkCyan 3 48
  132. DarkRed 4 64
  133. DarkMagenta 5 80
  134. Brown, DarkYellow 6 96
  135. LightGray 7 112
  136. DarkGray 8 128 *
  137. Blue, LightBlue 9 144 *
  138. Green, LightGreen 10 160 *
  139. Cyan, LightCyan 11 176 *
  140. Red, LightRed 12 192 *
  141. Magenta, LightMagenta 13 208 *
  142. Yellow, LightYellow 14 224 *
  143. White 15 240 *
  144. * Depending on the display mode, the color codes above 128 may not be
  145. available, and code 128 will make the text blink.
  146. When you use 0, the color is reset to the one used when you started Vim
  147. (usually 7, lightgray on black, but you can override this. If you have
  148. overridden the default colors in a command prompt, you may need to adjust
  149. some of the highlight colors in your vimrc---see below).
  150. This is the default for t_me.
  151. The defaults for the various highlight modes are:
  152. t_mr 112 reverse mode: Black text (0) on LightGray (112)
  153. t_md 15 bold mode: White text (15) on Black (0)
  154. t_me 0 normal mode (revert to default)
  155. t_so 31 standout mode: White (15) text on DarkBlue (16)
  156. t_se 0 standout mode end (revert to default)
  157. t_czh 225 italic mode: DarkBlue text (1) on Yellow (224)
  158. t_czr 0 italic mode end (revert to default)
  159. t_us 67 underline mode: DarkCyan text (3) on DarkRed (64)
  160. t_ue 0 underline mode end (revert to default)
  161. These colors were chosen because they also look good when using an inverted
  162. display, but you can change them to your liking.
  163. Example: >
  164. :set t_mr=^V^[\|97m " start of invert mode: DarkBlue (1) on Brown (96)
  165. :set t_md=^V^[\|67m " start of bold mode: DarkCyan (3) on DarkRed (64)
  166. :set t_me=^V^[\|112m " back to normal mode: Black (0) on LightGray (112)
  167. :set t_so=^V^[\|37m " start of standout mode: DarkMagenta (5) on DarkGreen
  168. (32)
  169. :set t_se=^V^[\|112m " back to normal mode: Black (0) on LightGray (112)
  170. ==============================================================================
  171. 5. File formats *dos-file-formats*
  172. If the 'fileformat' option is set to "dos" (which is the default), Vim accepts
  173. a single <NL> or a <CR><NL> pair for end-of-line (<EOL>). When writing a
  174. file, Vim uses <CR><NL>. Thus, if you edit a file and write it, Vim replaces
  175. <NL> with <CR><NL>.
  176. If the 'fileformat' option is set to "unix", Vim uses a single <NL> for <EOL>
  177. and shows <CR> as ^M.
  178. You can use Vim to replace <NL> with <CR><NL> by reading in any mode and
  179. writing in Dos mode (":se ff=dos").
  180. You can use Vim to replace <CR><NL> with <NL> by reading in Dos mode and
  181. writing in Unix mode (":se ff=unix").
  182. Vim sets 'fileformat' automatically when 'fileformats' is not empty (which is
  183. the default), so you don't really have to worry about what you are doing.
  184. |'fileformat'| |'fileformats'|
  185. If you want to edit a script file or a binary file, you should set the
  186. 'binary' option before loading the file. Script files and binary files may
  187. contain single <NL> characters which Vim would replace with <CR><NL>. You can
  188. set 'binary' automatically by starting Vim with the "-b" (binary) option.
  189. ==============================================================================
  190. 6. :cd command *dos-:cd*
  191. The ":cd" command recognizes the drive specifier and changes the current
  192. drive. Use ":cd c:" to make drive C the active drive. Use ":cd d:\foo" to go
  193. to the directory "foo" in the root of drive D. Vim also recognizes UNC names
  194. if the system supports them; e.g., ":cd \\server\share\dir". |:cd|
  195. ==============================================================================
  196. 7. Interrupting *dos-CTRL-Break*
  197. Use CTRL-Break instead of CTRL-C to interrupt searches. Vim does not detect
  198. the CTRL-C until it tries to read a key.
  199. ==============================================================================
  200. 8. Temp files *dos-temp-files*
  201. Only for the 16 bit and 32 bit DOS version:
  202. Vim puts temporary files (for filtering) in the first of these directories
  203. that exists and in which Vim can create a file:
  204. $TMP
  205. $TEMP
  206. C:\TMP
  207. C:\TEMP
  208. current directory
  209. For the Win32 version (both console and GUI):
  210. Vim uses standard Windows functions to obtain a temporary file name (for
  211. filtering). The first of these directories that exists and in which Vim can
  212. create a file is used:
  213. $TMP
  214. $TEMP
  215. current directory
  216. ==============================================================================
  217. 9. Shell option default *dos-shell*
  218. The default for the 'sh' ('shell') option is "command.com" on Windows 95 and
  219. "cmd.exe" on Windows NT. If SHELL is defined, Vim uses SHELL instead, and if
  220. SHELL is not defined but COMSPEC is, Vim uses COMSPEC. Vim starts external
  221. commands with "<shell> /c <command_name>". Typing CTRL-Z starts a new command
  222. subshell. Return to Vim with "exit". |'shell'| |CTRL-Z|
  223. If you are running a third-party shell, you may need to set the
  224. |'shellcmdflag'| ('shcf') and |'shellquote'| ('shq') or |'shellxquote'|
  225. ('sxq') options. Unfortunately, this also depends on the version of Vim used.
  226. For example, with the MKS Korn shell or with bash, the values of the options
  227. should be:
  228. DOS 16 bit DOS 32 bit Win32 ~
  229. 'shellcmdflag' -c -c -c
  230. 'shellquote' "
  231. 'shellxquote' "
  232. For Dos 16 bit this starts the shell as:
  233. <shell> -c "command name" >file
  234. For Win32 as:
  235. <shell> -c "command name >file"
  236. For DOS 32 bit, DJGPP does this internally somehow.
  237. When starting up, if Vim does not recognise a standard Windows shell it checks
  238. for the presence of "sh" anywhere in the 'shell' option. If it is present,
  239. Vim sets the 'shellcmdflag' and 'shellquote' or 'shellxquote' options will be
  240. set as described above.
  241. ==============================================================================
  242. 10. PowerShell *dos-powershell* *dos-pwsh*
  243. Vim supports PowerShell Desktop and PowerShell Core. PowerShell Desktop is
  244. the version of PowerShell that is installed with Windows, while PowerShell
  245. Core is a separate downloadable version that works cross-platform. To see
  246. which version you are using then enter the following in a PowerShell prompt -
  247. $PSVersionTable.PSEdition
  248. If 'shell' includes "powershell" in the filename at startup then VIM sets
  249. 'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
  250. following values:
  251. 'shellcmdflag' -Command
  252. 'shellxquote' "
  253. 'shellpipe' 2>&1 | Out-File -Encoding default
  254. 'shellredir' 2>&1 | Out-File -Encoding default
  255. If 'shell' includes "pwsh" in the filename at startup then VIM sets
  256. 'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
  257. following values:
  258. 'shellcmdflag' -c
  259. 'shellxquote' "
  260. 'shellpipe' >%s 2>&1
  261. 'shellredir' >%s 2>&1
  262. If you find that PowerShell commands are taking a long time to run then try
  263. with "-NoProfile" at the beginning of the 'shellcmdflag'. Note this will
  264. prevent any PowerShell environment setup by the profile from taking place.
  265. If you have problems running PowerShell scripts through the 'shell' then try
  266. with "-ExecutionPolicy RemoteSigned -Command" at the beginning of
  267. 'shellcmdflag'. See online Windows documentation for more information on
  268. PowerShell Execution Policy settings.
  269. See |option-backslash| about including spaces in 'shellcmdflag' when using
  270. multiple flags.
  271. The 'shellpipe' and 'shellredir' option values re-encode the UTF-16LE output
  272. from PowerShell Desktop to your currently configured console codepage. The
  273. output can be forced into a different encoding by changing "default" to one of
  274. the following:
  275. unicode - UTF-16LE (default output from PowerShell 5.1)
  276. bigendianunicode - UTF-16
  277. utf8 - UTF-8
  278. utf7 - UTF-7 (no BOM)
  279. utf32 - UTF-32
  280. ascii - 7-bit ASCII character set
  281. default - System's active code page (typically ANSI)
  282. oem - System's current OEM code page
  283. Note The above multi-byte Unicode encodings include a leading BOM unless
  284. otherwise indicated.
  285. By default PowerShell Core's output is UTF-8 encoded without a BOM. If you
  286. want to force the output of PowerShell Core into a different encoding then set
  287. 'shellredir' and 'shellpipe' to "2>&1 | Out-File -Encoding encoding" where
  288. encoding is one of the following:
  289. ascii - 7-bit ASCII character set
  290. bigendianunicode - UTF-16BE
  291. bigendianutf32 - UTF-32BE
  292. oem - System's current OEM code page
  293. unicode - UTF-16LE
  294. utf7 - UTF-7
  295. utf8 - UTF-8
  296. utf8BOM - UTF-8, with BOM
  297. utf8NoBOM - UTF-8, no BOM (default output from PowerShell Core)
  298. utf32 - UTF-32
  299. Since PowerShell Core 6.2, the Encoding parameter also supports specifying a
  300. numeric ID of a registered code page (-Encoding 1251) or string names of
  301. registered code pages (-Encoding "windows-1251"). The .NET documentation for
  302. Encoding.CodePage has more information
  303. vim:tw=78:ts=8:noet:ft=help:norl: