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