*os_msdos.txt*  For Vim version 5.0j.  Last modification: 1997 May 12


		  VIM REFERENCE MANUAL    by Bram Moolenaar


						*dos* *msdos* *ms-dos*
This file contains the particularities for the MS-DOS version of Vim.

1. Three versions for MS-DOS	|msdos-versions|
2. Known problems		|msdos-problems|
3. File locations		|msdos-locations|
4. Using backslashes		|msdos-backslash|
5. Long file names		|msdos-longfname|
6. Screen output and colors	|msdos-colors|
7. Termcap codes		|msdos-termcap|
8. Various			|msdos-various|

==============================================================================
1. Three versions for MS-DOS				*msdos-versions*

There are Three versions of Vim that can be used with MS-DOS machines:

Dos16 version	Can be used on any MS-DOS system, only uses up to
		640 Kbyte of memory.  Also runs on OS/2, Windows 95, and NT.
		Recommended for use on pre-386 machines.
Dos32 version	Requires 386 processor and a DPMI driver, uses all
		available memory.  Supports long file names, but NOT on
		Windows NT.  Recommended for MS-DOS, Windows 3.1 and Windows
		95.
Win32 version   Requires Windows 95 or Windows NT, uses all available
		memory, supports long file names, etc.  Has some problems on
		Windows 95.  Recommended for Windows NT.  See |os_win32.txt|

It is recommended to use the Dos32 or Win32 version.  Although the Dos16
version is able to edit very big files, it quickly runs out of memory when
making big changes.  Disabling undo helps: ":set ul=-1".  The screen updating
of the Dos16 version is the fastest of the three on DOS or Windows 95; on
Windows NT, the Win32 version is just as fast.

								*DPMI*
For the Dos32 version, you may need a DPMI driver when running in MS-DOS.  If
you are running Windows or installed a clever memory manager, it will probably
work already.  If you get the message "No DPMI", you need to install a DPMI
driver.  Such a driver is included with the executable in CSDPMI3b.zip.  Run
"cwsdpmi" just before starting Vim each time.  Or you might want to include
"cwsdpmi -p" in your autoexec.bat to make it resident.  The latest version of
"CSDPMI*.ZIP" can be obtained from: "ftp.neosoft.com:pub/users/s/sandmann".

==============================================================================
2. Known problems					*msdos-problems*

- When using smartdrive (MS-DOS 6.x) with write-behind caching, it is possible
  that Vim will try to create a swap file on a read-only file system (e.g.
  write protected floppy).  You will then be given the message
	"A serious disk error has occurred .., Retry (r)? " There is nothing
  you can do but unprotect the floppy or switch off the computer.  Even
  CTRL-ALT-DEL will not get you out of this.  This is really a problem of
  smartdrive, not Vim.  Smartdrive works fine otherwise.  If this bothers you,
  don't use the write-behind caching.
- Vim can't read swap files that have been opened already, unless the "share"
  command has been used.  If you see stray warnings for existing swap files,
  include the "share" command in your config.sys or autoexec.bat (see your
  MSDOS documentation).
- The Dos16 version can only have about 10 files open (in a window or hidden)
  at one time.  With more files you will get error messages when trying to
  read or write a file, and for filter commands.  Or Vim runs out of memory,
  and random problems may result.
- The Dos32 version can only have about 15 files open (in a window or hidden)
  at one time.  With more files, shell commands may cause a crash!
- The Dos32 version can work with long file names.  When doing file name
  completion, matches for the short file name will also be found.  But this
  will result in the corresponding long file name.  For example, if you have
  the long file name "this_is_a_test" with the short file name "this_i~1", the
  command ":e *1" will start editing "this_is_a_test".
- When using the Dos32 version and you run into problems with DPMI support,
  check if there is a program in your config.sys that eats resources.  One
  program known to cause this problem is "netx", which says "NetWare v. 3.26
  Workstation shell".  Replace it with version 3.32 to fix the problem.

==============================================================================
3. File locations					*msdos-locations*

You should set the environment variable "VIM" to the directory where the Vim
documentation files are.  If "VIM" is used but not defined, "HOME" is tried
too.

If the HOME environment variable is not set, the value "C:/" is used as a
default.

The default help file name is "$VIM\doc\help.txt".  If the environment variable
$VIM is not defined or the file is not found, the DOS search path is used to
search for the file "help.txt".  If you do not want to put "help.txt" in your
search path, use the command ":set helpfile=pathname" to tell Vim where the
help file is.  Also see |$VIM| and |'helpfile'|.

Vim will look for initializations in eight places.  The first that is found
is used and the others are ignored.  The order is:
	-  The environment variable VIMINIT
	-  The file "$VIM/_vimrc"
	-  The file "$HOME/_vimrc"
	-  The file "$VIM/.vimrc"
	-  The file "$HOME/.vimrc"
	-  The environment variable EXINIT
	-  The file "$VIM/_exrc"
	-  The file "$HOME/_exrc"

==============================================================================
4. Using backslashes					*msdos-backslash*

Using backslashes in file names can be a problem.  Vi halves the number of
backslashes for some commands.  Vim is a bit more tolerant and backslashes
are not removed from a file name, so ":e c:\foo\bar" works as expected.  But
when a backslash is used before a special character (space, comma, backslash,
etc.), it is removed.  Use slashes to avoid problems: ":e c:/foo/bar" works
fine.  Vim will replace the slashes with backslashes internally, to avoid
problems with some MS-DOS programs.

==============================================================================
5. Long file names					*msdos-longfname*

If the Dos32 version is run on Windows 95, it can use long file names.  It
will work by default.  If you want to disable this, use this setting:
	set LFN=N
You can put this in your autoexec.bat file.

Note: If you have installed DJGPP on your machine, you probably have a
"djgpp.env" file, which contains "LFN=n".  You need to use "LFN=Y" to switch
on using long file names then.

==============================================================================
6. Screen output and colors				*msdos-colors*

The default output method for the screen is to use bios calls.  This will work
right away on most systems.  You do not need ansi.sys.  You can use ":mode" to
set the current screen mode.  See |:mode|.

You can set the color used in five modes with nine termcap options.  Which of
the five modes is used for which action depends on the |'highlight'| option.

	":set t_mr=^V^[\|xxm"		start of invert mode
	":set t_md=^V^[\|xxm"		start of bold mode
	":set t_me=^V^[\|xxm"		back to normal text

	":set t_so=^V^[\|xxm"		start of standout mode
	":set t_se=^V^[\|xxm"		back to normal text

	":set t_us=^V^[\|xxm"		start of underline mode
	":set t_ue=^V^[\|xxm"		back to normal text

	":set t_ZH=^V^[\|xxm"		start of italics mode
	":set t_ZR=^V^[\|xxm"		back to normal text

^V is CTRL-V
^[ is <Esc>
xx must be replaced with a decimal code, which is the foreground color number
   and background color number added together:

COLOR			FOREGROUND	BACKGROUND
Black			    0		    0
DarkBlue		    1		   16
DarkGreen		    2		   32
DarkCyan		    3		   48
DarkRed			    4		   64
DarkMagenta		    5		   80
Brown			    6		   96
LighGray		    7		  112
DarkGray		    8		  128 *
Blue, LightBlue		    9		  144 *
Green, LightGreen	   10		  160 *
Cyan, LightCyan		   11		  176 *
Red, LightRed		   12		  192 *
Magenta, LightMagenta	   13		  208 *
Yellow			   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 color is reset to the one used when you started Vim.
This is the default for t_me.

The defaults for the various highlight modes are:
	t_mr	112	 reverse mode: Black text (0) on LightGray (112)
	t_md	 15	 bold mode: White text (15) on Black (0)
	t_me	  0	 normal mode (revert to default)

	t_so	 31	 standout mode: White (15) text on DarkBlue (16)
	t_se	  0	 standout mode end (revert to default)

	t_czh	225	 italic mode: DarkBlue text (1) on Yellow (224)
	t_czr	  0	 italic mode end (revert to default)

	t_us	 67	 underline mode: DarkCyan text (3) on DarkRed (64)
	t_ue	  0	 underline mode end (revert to default)

These colors were chosen because they also look good when using an inverted
display, 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)

==============================================================================
7. Termcap codes					*msdos-termcap*

The termcap codes that are translated into bios calls are:
	t_cl	<Esc>|J			clear screen
	t_ce	<Esc>|K			clear to end of line
	t_al	<Esc>|L			insert line
	t_dl	<Esc>|M			delete line
	t_cm	<Esc>|{row};{col}H	position cursor
	t_cs	<Esc>|{row};{row}r	set scrolling region
	t_..	<Esc>|attrm		set character attribute

If you set these with the ":set" command, don't forget to put a backslash
before the '|', otherwise it will be recognized as the end of the command.

If you want to use another output method (e.g., when using a terminal on a COM
port), set the terminal name to "pcansi".  You can change the termcap options
when needed (see |terminal_options|).  Note that the
normal IBM ansi.sys does not support all the codes of the builtin pcansi
terminal.  If you use ansi.sys, you will need to delete the termcap entries
t_al and t_dl with
	":set t_al= t_dl=".
Otherwise, the screen will not be updated correctly.  It is better to use
nansi.sys, nnansi.sys, or the like instead of ansi.sys.

If you want to use Vim on a terminal connected to a COM: port, reset the
'bioskey' option.  Otherwise the commands will be read from the PC keyboard.
CTRL-C and CTRL-P may not work correctly with 'bioskey' reset.

==============================================================================
8. Various						*msdos-various*

TEXTMODE or NON-MS-DOS FILES

If the "tx" (textmode) option is set (which is the default), Vim will accept
a single <NL> or a <CR><NL> pair for end-of-line.  When writing a file, Vim
will use <CR><NL>.  Thus, if you edit a file and write it, <NL> is replaced
with <CR><NL>.  If the "tx" option is not set, a single <NL> will be used
for end-of-line.  A <CR> will be shown as ^M.  You can use Vim to replace
<NL> with <CR><NL> by reading in any mode and writing in text mode (":se
tx").  You can use Vim to replace <CR><NL> with <NL> by reading in text mode
and writing in non-text mode (":se notx"). 'textmode' is set automatically
when 'textauto' is on (which is the default), so you don't really have to
worry about what you are doing.			|'textmode'| |'textauto'|

If you want to edit a script file or a binary file, you should reset the
'textmode' and 'textauto' options before loading the file.  Script files and
binary files may contain single <NL> characters which would be replaced with
<CR><NL>.  You can reset 'textmode' and 'textauto' automatically by starting
Vim with the "-b" (binary) option.


:CD COMMAND

The ":cd" command recognizes the drive specifier and changes the current
drive.  Use ":cd c:" to make drive C the active drive.  Use ":cd d:\dos" to go
to the directory "dos" in the root of drive D.	|:cd|


INTERRUPTING						*CTRL-Break*

Use CTRL-Break instead of CTRL-C to interrupt searches.  The CTRL-C is not
detected until a key is read.


SHIFTED ARROW KEYS

Use CTRL-arrow-left and CTRL-arrow-right instead of SHIFT-arrow-left and
SHIFT-arrow-right.  The arrow-up and arrow-down cannot be used with SHIFT or
CTRL.


TEMP FILES

Temporary files (for filtering) are put in the first directory in the next
list that exists and where a file can be created:
	$TMP
	$TEMP
	C:\TMP
	C:\TEMP
	current directory


SHELL OPTION DEFAULT

The default for the sh (shell) option is "command".  If COMSPEC is defined it
is used instead.  External commands are started with
"command /c <command_name>".  Typing CTRL-Z starts a new command shell.
Return to Vim with "exit".


FILENAME EXTENSIONS

MS-DOS allows for only one file name extension.  Therefore, when appending an
extension, the '.' in the original file name is replaced with a '_', the name
is truncated to 8 characters, and the new extension (e.g., ".swp") is
appended.  Two examples: "test.c" becomes "test_c.bak", "thisisat.est"
becomes "thisisat.bak".  To reduce these problems, the default for
'backupext' is "~" instead of ".bak".  The backup file for "thisisat.est"
then becomes "thisisat.es~".  The 'shortname' option is not available,
because it would always be set.


COMPILING

The MS-DOS binary was compiled with Borland-C++ version 4.0, using
makefile.bcc.  Other compilers should also work.  Use makefile.dos for
Turbo-C 2.0.  Use makefile.bcc for other Borland compilers, also Turbo-C++
3.0 (with small changes).  If you get all kinds of strange error messages
when compiling, try adding <CR> characters at the end of each line.  This can
be done with the addcr program: "make addcr".  This will compile addcr.c to
addcr.exe and then execute the addcr.bat file.  Sometimes this fails.  In
that case, execute the addcr.bat file from the DOS prompt.

The "spawno" library by Ralf Brown was used in order to free memory when Vim
starts a shell or other external command.  Only about 200 bytes are taken from
conventional memory.  When recompiling get the spawno library from Simtel,
directory "msdos/c".  It is called something like "spwno413.zip".  Or remove
the library from the makefile.


MEMORY USAGE and LIMITATIONS

A swap file is used to store most of the text.  You should be able to edit
very large files.  However, memory is used for undo and other things.  If you
delete a lot of text, you can still run out of memory in the Dos16 version.

If Vim gives an "Out of memory" warning, you should stop editing.  The result
of further editing actions is unpredictable.  Setting 'undolevels' to 0 saves
some memory.  Running the maze macros on a big maze is guaranteed to run out
of memory, because each change is remembered for undo.  In this case set
'undolevels' to a negative number.  This will switch off undo completely.

In the Dos32 version, extended memory is used to avoid these problems.

In the Dos16 version the line length is limited to about 32000 characters.
When reading a file the lines are automatically split.  But editing a line
in such a way that it becomes too long may give unexpected results.


USING VIM TO EDIT A SYMBOLICALLY LINKED FILE ON A UNIX NFS FILE SERVER

When writing the file, Vim does not "write through" the symlink.  Instead, it
deletes the symbolic link and creates a new file in its place.
   On Unix, Vim is prepared for links (symbolic or hard).  A backup copy of
the original file is made and then the original file is overwritten.  This
assures that all properties of the file remain the same.  On non-Unix systems,
the original file is renamed and a new file is written.  Only the protection
bits are set like the original file.  However, this doesn't work properly when
working on an NFS-mounted file system where links and other things exist.  The
only way to fix this in the current version is not making a backup file, by
":set nobackup nowritebackup"	|'writebackup'|


HOW TO COPY/PASTE TEXT FROM/TO VIM IN A DOS BOX

(posted to comp.editors by John Velman <velman@igate1.hac.com>)

1) to get VIM to run in a window, instead of full screen, press alt+enter.
   This toggles back and forth between full screen and a dos window.
   NOTE: In Windows 95 you must have the property "Fast Pasting" unchecked!
   In the properties dialog box for the MS-DOS window, go to "MS-DOS
   Prompt/Misc/Fast pasting" and make sure that it is NOT checked.

2) To paste something _into_ Vim, put Vim in insert mode.

3) put the text you want to paste on the windows clipboard.

4) Click the control box in the upper left of the Vim window. (This looks
   like a big minus sign). If you don't want to use the mouse, you can get
   this with alt+spacebar.
5) on the resulting dropdown menu choose "Edit"
6) on the child dropdown menu choose "Paste"

To copy something from the Vim window to the clipboard,

1) select the control box to get the control drop down menu.
2) select "Edit".
3) select "Mark"
4) using either the the keys or the mouse, select the part of the Vim window
   that you want to copy. To use the keys, use the arrow keys, and hold down
   shift to extend the selection.
5) when you've completed your selection, press 'enter.' The selection
   is now in the windows clipboard. By the way, this can be any
   rectangular selection, for example columns 4-25 in rows 7-10. It can
   include anything in the VIM window: the output of a :!dir, for
   example.

 vim:ts=8:sw=8:tw=78:
