*editing.txt*   For Vim version 7.0aa.  Last change: 2004 Aug 29


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Editing files						*edit-files*

1.  Introduction		|edit-intro|
2.  Editing a file		|edit-a-file|
3.  Dialogs			|edit-dialogs|
4.  The current directory	|current-directory|
5.  The argument list		|argument-list|
6.  Writing			|writing|
7.  Writing and quitting	|write-quit|
8.  Editing binary files	|edit-binary|
9.  Encryption			|encryption|
10. Timestamps			|timestamps|

==============================================================================
1. Introduction						*edit-intro*

Editing a file with Vim means:

1. reading the file into the internal buffer
2. changing the buffer with editor commands
3. writing the buffer into a file

							*current-file*
As long as you don't write the buffer, the original file remains unchanged.
If you start editing a file (read a file into the buffer), the file name is
remembered as the "current file name".  This is also known as the name of the
current buffer.

							*alternate-file*
If there already was a current file name, then that one becomes the alternate
file name.  It can later be used with "#" on the command line |:_#|.  However,
the alternate file name is not changed when |:keepalt| is used.

							*:keepalt* *:keepa*
:keepalt {cmd}		Execute {cmd} while keeping the current alternate file
			name.  Note that commands invoked indirectly (e.g.,
			with a function) may still set the alternate file
			name.  {not in Vi}

All file names are remembered in the file list.  When you enter a file name,
for editing (e.g., with ":e filename") or writing (e.g., with (:w file name"),
the file name is added to the list.  You can use this list to remember which
files you edited and to quickly switch from one file to another with the
CTRL-^ command (e.g., to copy text).  First type the number of the file and
then hit CTRL-^.  {Vi: only one alternate file name}

CTRL-G		or				*CTRL-G* *:f* *:fi* *:file*
:f[ile]			Prints the current file name (as typed), the
			cursor position (unless the 'ruler' option is set),
			and the file status (readonly, modified, read errors,
			new file)).  See the 'shortmess' option about how tho
			make this message shorter.  {Vi does not include
			column number}

:f[ile]!		like |:file|, but don't truncate the name even when
			'shortmess' indicates this.

{count}CTRL-G		Like CTRL-G, but prints the current file name with
			full path.  If the count is higher than 1 the current
			buffer number is also given.  {not in Vi}

					*g_CTRL-G* *word-count* *byte-count*
g CTRL-G		Prints the current position of the cursor in four
			ways: Column, Line, Word and Byte.  If there are
			characters in the line that take more than one
			position on the screen (<Tab> or special character),
			both the "real" column and the screen column are
			shown, separated with a dash.  See also 'ruler'
			option.  {not in Vi}

							*v_g_CTRL-G*
{Visual}g CTRL-G	Similar to "g CTRL-G", but Word, Line, and Byte counts
			for the visually selected region are displayed.  In
			Blockwise mode, Column count is also shown.  (For
			{Visual} see |Visual-mode|.)
			{not in VI}

							*:file_f*
:f[ile][!] {name}	Sets the current file name to {name}.  The optional !
			avoids truncating the message, as with |:file|.

:0f[ile][!]		Remove the name of the current buffer.  The optional !
			avoids truncating the message, as with |:file|.  {not
			in Vi}

:buffers
:files
:ls			List all the currently known file names.  See
			'windows.txt' |:files| |:buffers| |:ls|.  {not in
			Vi}

Vim will remember the full path name of a file name that you enter.  In most
cases when the file name is displayed only the name you typed is shown, but
the full path name is being used if you used the ":cd" command |:cd|.

							*home-replace*
If the environment variable $HOME is set, and the file name starts with that
string, it is often displayed with HOME replaced with "~".  This was done to
keep file names short.  When reading or writing files the full name is still
used, the "~" is only used when displaying file names.  When replacing the
file name would result in just "~", "~/" is used instead (to avoid confusion
with 'backupext' set to "~").

When writing the buffer, the default is to use the current file name.  Thus
when you give the "ZZ" or ":wq" command, the original file will be
overwritten.  If you do not want this, the buffer can be written into another
file by giving a file name argument to the ":write" command.  For example: >

	vim testfile
	[change the buffer with editor commands]
	:w newfile
	:q

This will create a file "newfile", that is a modified copy of "testfile".
The file "testfile" will remain unchanged.  Anyway, if the 'backup' option is
set, Vim renames or copies the original file before it will be overwritten.
You can use this file if you discover that you need the original file.  See
also the 'patchmode' option.  The name of the backup file is normally the same
as the original file with 'backupext' appended.  The default "~" is a bit
strange to avoid accidentally overwriting existing files.  If you prefer ".bak"
change the 'backupext' option.  Extra dots are replaced with '_' on MS-DOS
machines, when Vim has detected that an MS-DOS-like filesystem is being used
(e.g., messydos or crossdos) or when the 'shortname' option is on.  The
backup file can be placed in another directory by setting 'backupdir'.

							*auto-shortname*
Technical: On the Amiga you can use 30 characters for a file name.  But on an
	   MS-DOS-compatible filesystem only 8 plus 3 characters are
	   available.  Vim tries to detect the type of filesystem when it is
	   creating the .swp file.  If an MS-DOS-like filesystem is suspected,
	   a flag is set that has the same effect as setting the 'shortname'
	   option.  This flag will be reset as soon as you start editing a
	   new file.  The flag will be used when making the file name for the
	   ".swp" and ".~" files for the current file.  But when you are
	   editing a file in a normal filesystem and write to an MS-DOS-like
	   filesystem the flag will not have been set.  In that case the
	   creation of the ".~" file may fail and you will get an error
	   message.  Use the 'shortname' option in this case.

When you started editing without giving a file name, "No File" is displayed in
messages.  If the ":write" command is used with a file name argument, the file
name for the current file is set to that file name.  This only happens when
the 'F' flag is included in 'cpoptions' (by default it is included).  This is
useful when entering text in an empty buffer and then writing it to a file.
If 'cpoptions' contains the 'f' flag (by default it is NOT included) the file
name is set for the ":read file" command.  This is useful when starting Vim
without an argument and then doing ":read file" to start editing a file.
							*not-edited*
Because the file name was set without really starting to edit that file, you
are protected from overwriting that file.  This is done by setting the
"notedited" flag.  You can see if this flag is set with the CTRL-G or ":file"
command.  It will include "[Not edited]" when the "notedited" flag is set.
When writing the buffer to the current file name (with ":w!"), the "notedited"
flag is reset.

							*abandon*
Vim remembers whether you have changed the buffer.  You are protected from
losing the changes you made.  If you try to quit without writing, or want to
start editing another file, Vim will refuse this.  In order to overrule this
protection, add a '!' to the command.  The changes will then be lost.  For
example: ":q" will not work if the buffer was changed, but ":q!" will.  To see
whether the buffer was changed use the "CTRL-G" command.  The message includes
the string "[Modified]" if the buffer has been changed.

If you want to automatically save the changes without asking, switch on the
'autowriteall' option.  'autowrite' is the associated Vi-compatible option
that does not work for all commands.

If you want to keep the changed buffer without saving it, switch on the
'hidden' option.  See |hidden-buffer|.

==============================================================================
2. Editing a file					*edit-a-file*

							*:e* *:edit*
:e[dit] [++opt] [+cmd]	Edit the current file.  This is useful to re-edit the
			current file, when it has been changed outside of Vim.
			This fails when changes have been made to the current
			buffer and 'autowriteall' isn't set or the file can't
			be written.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

							*:edit!*
:e[dit]! [++opt] [+cmd]
			Edit the current file always.  Discard any changes to
			the current buffer.  This is useful if you want to
			start all over again.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

							*:edit_f*
:e[dit] [++opt] [+cmd] {file}
			Edit {file}.
			This fails when changes have been made to the current
			buffer, unless 'hidden' is set or 'autowriteall' is
			set and the file can be written.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

							*:edit!_f*
:e[dit]! [++opt] [+cmd] {file}
			Edit {file} always.  Discard any changes to the
			current buffer.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

:e[dit] [++opt] [+cmd] #[count]
			Edit the [count]th alternate file name (as shown by
			:files).  This command does the same as
			[count] CTRL-^.  But ":e #" doesn't work if the
			alternate buffer doesn't have a file name, while
			CTRL-^ still works then.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

							*:ene* *:enew*
:ene[w]			Edit a new, unnamed buffer.  This fails when changes
			have been made to the current buffer, unless 'hidden'
			is set or 'autowriteall' is set and the file can be
			written.
			If 'fileformats' is not empty, the first format given
			will be used for the new buffer.  If 'fileformats' is
			empty, the 'fileformat' of the current buffer is used.
			{not in Vi}

							*:ene!* *:enew!*
:ene[w]!		Edit a new, unnamed buffer.  Discard any changes to
			the current buffer.
			Set 'fileformat' like |:enew|.
			{not in Vi}

							*:fin* *:find*
:fin[d][!] [++opt] [+cmd] {file}
			Find {file} in 'path' and then |:edit| it.
			{not in Vi} {not available when the |+file_in_path|
			feature was disabled at compile time}

:{count}fin[d][!] [++opt] [+cmd] {file}
			Just like ":find", but use the {count} match in
			'path'.  Thus ":2find file" will find the second
			"file" found in 'path'.  When there are fewer matches
			for the file in 'path' than asked for, you get an
			error message.

							*:ex*
:ex [++opt] [+cmd] [file]
			Same as |:edit|.

							*:vi* *:visual*
:vi[sual][!] [++opt] [+cmd] [file]
			When entered in Ex mode: Leave |Ex-mode|, go back to
			Normal mode.  Otherwise same as |:edit|.

							*:vie* *:view*
:vie[w] [++opt] [+cmd] file
			When entered in Ex mode: Leave Ex mode, go back to
			Normal mode.  Otherwise same as |:edit|, but set
			'readonly' option for this buffer.  {not in Vi}

							*CTRL-^* *CTRL-6*
[count]CTRL-^		Edit [count]th alternate file (equivalent to ":e
			#[count]").  Without count this gets you to the
			previously edited file.  This is a quick way to toggle
			between two (or more) files.
			If the 'autowrite' or 'autowriteall' option is on and
			the buffer was changed, write it.
			Mostly the ^ character is positioned on the 6 key,
			pressing CTRL and 6 then gets you what we call CTRL-^.
			But on some non-US keyboards CTRL-^ is produced in
			another way.

[count]]f						*]f* *[f*
[count][f		Same as "gf".  Deprecated.

							*gf* *E446* *E447*
[count]gf		Edit the file whose name is under or after the cursor.
			Mnemonic: "goto file".
			Uses the 'isfname' option to find out which characters
			are supposed to be in a file name.  Trailing
			punctuation characters ".,:;!" are ignored.
			Uses the 'path' option as a list of directory names
			to look for the file.  Also looks for the file
			relative to the current file.
			Uses the 'suffixesadd' option to check for file names
			with a suffix added.
			If the file can't be found, 'includeexpr' is used to
			modify the name and another attempt is done.
			If a [count] is given, the count'th file that is found
			in the 'path' is edited.
			This command fails if Vim refuses to |abandon| the
			current file.
			If you do want to edit a new file, use: >
				:e <cfile>
<			To make gf always work like that: >
				:map gf :e <cfile><CR>
<			If the name is a hypertext link, that looks like
			"type://machine/path", you need the |netrw| plugin.
			For Unix the '~' character is expanded, like in
			"~user/file".  Environment variables are expanded too
			|expand-env|.
			{not in Vi}
			{not available when the |+file_in_path| feature was
			disabled at compile time}

							*v_gf*
{Visual}[count]gf	Same as "gf", but the highlighted text is used as the
			name of the file to edit.  'isfname' is ignored.
			Leading blanks are skipped, otherwise all blanks and
			special characters are included in the file name.
			(For {Visual} see |Visual-mode|.)
			{not in VI}

These commands are used to start editing a single file.  This means that the
file is read into the buffer and the current file name is set.  The file that
is opened depends on the current directory, see |:cd|.

See |read-messages| for an explanation of the message that is given after the
file has been read.

You can use the ":e!" command if you messed up the buffer and want to start
all over again.  The ":e" command is only useful if you have changed the
current file name.

							*:filename* *{file}*
Note for systems other than Unix and MS-DOS: When using a command that
accepts a single file name (like ":edit file") spaces in the file name are
allowed, but trailing spaces are ignored.  This is useful on systems that
allow file names with embedded spaces (like the Amiga).  Example: The command
":e   Long File Name " will edit the file "Long File Name".  When using a
command that accepts more than one file name (like ":next file1 file2")
embedded spaces must be escaped with a backslash.

Wildcards in {file} are expanded.  Which wildcards are supported depends on
the system.  These are the common ones:
	*	matches anything, including nothing
	?	matches one character
	[abc]	match 'a', 'b' or 'c'
To avoid the special meaning of the wildcards prepend a backslash.  However,
on MS-Windows the backslash is a path separator and "path\[abc]" is still seen
as a wildcard when "[" is in the 'isfname' option.  A simple way to avoid this
is to use "path\[[]abc]".  Then the file "path[abc]" literally.

					*backtick-expansion* *`-expansion*
On Unix you can also use backticks in the file name, for example: >
	:e `find . -name ver\\*.c -print`
The backslashes before the star are required to prevent "ver*.c" to be
expanded by the shell before executing the find program.
This also works for most other systems, with the restriction that the
backticks must be around the whole item.  It is not possible to have text
directly before the first or just after the last backtick.

							*`=*
You can have the backticks expanded as a Vim expression, instead of
an external command, by using the syntax `={expr}` e.g.: >
	:let foo='bar'
	:e `=foo . ".c" `
This will edit "bar.c".  The expression can contain just about anything, thus
this can also be used to avoid the special meaning of '"', '|', '%' and '#'.

							*++opt* *[++opt]*
The [++opt] argument can be used to force the value of 'fileformat' or
'fileencoding' to a value for one command.  The form is: >
	++{optname}={value}

Where {optname} is one of:		*++ff* *++enc* *++bin* *++nobin*
    ff     or  fileformat   overrides 'fileformat'
    enc    or  encoding	    overrides 'fileencoding'
    bin    or  binary	    sets 'binary'
    nobin  or  nobinary	    resets 'binary'

{value} cannot contain white space.  It can be any valid value for these
options.  Examples: >
	:e ++ff=unix
This edits the same file again with 'fileformat' set to "unix". >

	:w ++enc=latin1 newfile
This writes the current buffer to "newfile" in latin1 format.

Note that when reading, the 'fileformat' and 'fileencoding' options will be
set to the used format.  When writing this doesn't happen, thus a next write
will use the old value of the option.  Same for the 'binary' option.

There may be several ++opt arguments, separated by white space.  They must all
appear before any |+cmd| argument.

							*+cmd* *[+cmd]*
The [+cmd] argument can be used to position the cursor in the newly opened
file, or execute any other command:
	+		Start at the last line.
	+{num}		Start at line {num}.
	+/{pat}		Start at first line containing {pat}.
	+{command}	Execute {command} after opening the new file.
			{command} is any Ex command.
To include a white space in the {pat} or {command}, precede it with a
backslash.  Double the number of backslashes. >
	:edit  +/The\ book	     file
	:edit  +/dir\ dirname\\      file
	:edit  +set\ dir=c:\\\\temp  file
Note that in the last example the number of backslashes is halved twice: Once
for the "+cmd" argument and once for the ":set" command.

							*file-formats*
The 'fileformat' option sets the <EOL> style for a file:
'fileformat'    characters	   name				~
  "dos"		<CR><NL> or <NL>   DOS format		*DOS-format*
  "unix"	<NL>		   Unix format		*Unix-format*
  "mac"		<CR>		   Mac format		*Mac-format*
Previously 'textmode' was used.  It is obsolete now.

When reading a file, the mentioned characters are interpreted as the <EOL>.
In DOS format (default for MS-DOS, OS/2 and Win32), <CR><NL> and <NL> are both
interpreted as the <EOL>.  Note that when writing the file in DOS format,
<CR> characters will be added for each single <NL>.  Also see |file-read|.

When writing a file, the mentioned characters are used for <EOL>.  For DOS
format <CR><NL> is used.  Also see |DOS-format-write|.

You can read a file in DOS format and write it in Unix format.  This will
replace all <CR><NL> pairs by <NL> (assuming 'fileformats' includes "dos"): >
	:e file
	:set fileformat=unix
	:w
If you read a file in Unix format and write with DOS format, all <NL>
characters will be replaced with <CR><NL> (assuming 'fileformats' includes
"unix"): >
	:e file
	:set fileformat=dos
	:w

If you start editing a new file and the 'fileformats' option is not empty
(which is the default), Vim will try to detect whether the lines in the file
are separated by the specified formats.  When set to "unix,dos", Vim will
check for lines with a single <NL> (as used on Unix and Amiga) or by a <CR>
<NL> pair (MS-DOS).  Only when ALL lines end in <CR><NL>, 'fileformat' is set
to "dos", otherwise it is set to "unix".  When 'fileformats' includes "mac",
and no <NL> characters are found in the file, 'fileformat' is set to "mac".

If the 'fileformat' option is set to "dos" on non-MS-DOS systems the message
"[dos format]" is shown to remind you that something unusual is happening.  On
MS-DOS systems you get the message "[unix format]" if 'fileformat' is set to
"unix".  On all systems but the Macintosh you get the message "[mac format]"
if 'fileformat' is set to "mac".

If the 'fileformats' option is empty and DOS format is used, but while reading
a file some lines did not end in <CR><NL>, "[CR missing]" will be included in
the file message.
If the 'fileformats' option is empty and Mac format is used, but while reading
a file a <NL> was found, "[NL missing]" will be included in the file message.

If the new file does not exist, the 'fileformat' of the current buffer is used
when 'fileformats' is empty.  Otherwise the first format from 'fileformats' is
used for the new file.

Before editing binary, executable or Vim script files you should set the
'binary' option.  A simple way to do this is by starting Vim with the "-b"
option.  This will avoid the use of 'fileformat'.  Without this you risk that
single <NL> characters are unexpectedly replaced with <CR><NL>.

You can encrypt files that are written by setting the 'key' option.  This
provides some security against others reading your files. |encryption|


File Searching						*file-searching*

{not available when compiled without the |+path_extra| feature}

The file searching is currently used for the 'path', 'cdpath' and 'tags'
options.  There are three different types of searching:

1) Downward search:
   Downward search uses the wildcards '*', '**' and possibly others
   supported by your operating system. '*' and '**' are handled inside Vim, so
   they work on all operating systems.

   The usage of '*' is quite simple: It matches 0 or more characters.

   '**' is more sophisticated:
      - It ONLY matches directories.
      - It matches up to 30  directories deep, so you can use it to search an
	entire directory tree
      - The maximum number of levels matched can be given by appending a number
	to '**'.
	Thus '/usr/**2' can match: >
		/usr
		/usr/include
		/usr/include/sys
		/usr/include/g++
		/usr/lib
		/usr/lib/X11
		....
<	It does NOT match '/usr/include/g++/std' as this would be three
	levels.
	The allowed number range is 0 ('**0' is removed) to 255.
	If the given number is smaller than 0 it defaults to 30, if it's
	bigger than 255 it defaults to 255.
      - '**' can only be at the end of the path or be followed by a path
	separator or by a number and a path separator.

   You can combine '*' and '**' in any order: >
	/usr/**/sys/*
	/usr/*/sys/**
	/usr/**2/sys/*

2) Upward search:
   Here you can give a directory and then search the directory tree upward for
   a file. You could give stop-directories to limit the upward search. The
   stop-directories are appended to the path (for the 'path' option) or to
   the filename (for the 'tags' option) with a ';'. If you want several
   stop-directories separate them with ';'. If you want no stop-directory
   ("search upward till the root directory) just use ';'. >
	/usr/include/sys;/usr
<   will search in: >
	   /usr/include/sys
	   /usr/include
	   /usr
<
   If you use a relative path the upward search is started in Vim's current
   directory or in the directory of the current file (if the relative path
   starts with './' and 'd' is not included in 'cpoptions').

   If Vim's current path is /u/user_x/work/release and you do >
	:set path=include;/u/user_x
<  and then search for a file with |gf| the file is searched in: >
	/u/user_x/work/release/include
	/u/user_x/work/include
	/u/user_x/include

3) Combined up/downward search
   If Vim's current path is /u/user_x/work/release and you do >
	set path=**;/u/user_x
<  and then search for a file with |gf| the file is searched in: >
	/u/user_x/work/release/**
	/u/user_x/work/**
	/u/user_x/**
<
   BE CAREFUL! This might consume a lot of time, as the search of
   '/u/user_x/**' includes '/u/user_x/work/**' and
   '/u/user_x/work/release/**'.  So '/u/user_x/work/release/**' is searched
   three and '/u/user_x/work/**' is searched two times.

   In the above example you might want to set path to: >
	:set path=**,/u/user_x/**
<   This searches: >
	/u/user_x/work/release/**
	/u/user_x/**
<   This searches the same directories, but in a different order.

==============================================================================
3. Dialogs						*edit-dialogs*

							*:confirm* *:conf*
:conf[irm] {command}	Execute {command}, and use a dialog when an
			operation has to be confirmed.  Can be used on the
			":q", ":qa" and ":w" commands (the latter to over-ride
			a read-only setting).

Examples: >
  :confirm w foo
<	Will ask for confirmation when "foo" already exists. >
  :confirm q
<	Will ask for confirmation when there are changes. >
  :confirm qa
<	If any modified, unsaved buffers exist, you will be prompted to save
	or abandon each one.  There are also choices to "save all" or "abandon
	all".

If you want to always use ":confirm", set the 'confirm' option.

			*:browse* *:bro* *E338* *E614* *E615* *E616* *E578*
:bro[wse] {command}	Open a file selection dialog for an argument to
			{command}.  At present this works for |:e|, |:w|,
			|:r|, |:saveas|, |:sp|, |:mkexrc|, |:mkvimrc| and
			|:mksession|.
			{only in Win32, Athena, Motif, GTK and Mac GUI}
			When ":browse" is not possible you get an error
			message.  If the |+browse| feature is missing or the
			{command} doesn't support browsing, the {command} is
			executed without a dialog.
			":browse set" works like |:options|.

The syntax is best shown via some examples: >
	:browse e $vim/foo
<		Open the browser in the $vim/foo directory, and edit the
		file chosen. >
	:browse e
<		Open the browser in the directory specified with 'browsedir',
		and edit the file chosen. >
	:browse w
<		Open the browser in the directory of the current buffer,
		with the current buffer filename as default, and save the
		buffer under the filename chosen. >
	:browse w C:/bar
<		Open the browser in the C:/bar directory, with the current
		buffer filename as default, and save the buffer under the
		filename chosen.
Also see the |'browsedir'| option.
For versions of Vim where browsing is not supported, the command is executed
unmodified.

							*browsefilter*
For MS Windows, you can modify the filters that are used in the browse dialog.
By setting the g:browsefilter or b:browsefilter variables, you can change the
filters globally or locally to the buffer.  The variable is set to a string in
the format "{filter label}\t{pattern};{pattern}\n" where {filter label} is the
text that appears in the "Files of Type" comboBox, and {pattern} is the
pattern which filters the filenames.  Several patterns can be given, separated
by ';'.

For Motif the same format is used, but only the very first pattern is actually
used (Motif only offers one pattern, but you can edit it).

For example, to have only Vim files in the dialog, you could use the following
command: >

     let g:browsefilter="Vim Scripts\t*.vim\nVim Startup Files\t*vimrc\n"

You can override the filter setting on a per-buffer basis by setting the
b:browsefilter variable.  You would most likely set b:browsefilter in a
filetype plugin, so that the browse dialog would contain entries related to
the type of file you are currently editing.  Disadvantage: This makes it
difficult to start editing a file of a different type.  To overcome this, you
may want to add "All Files\t*.*\n" as the final filter, so that the user can
still access any desired file.

==============================================================================
4. The current directory				*current-directory*

You may use the |:cd| and |:lcd| commands to change to another directory, so
you will not have to type that directory name in front of the file names.  It
also makes a difference for executing external commands, e.g. ":!ls".

							*:cd* *E472*
:cd			On non-Unix systems: Print the current directory
			name.  On Unix systems: Change the current directory
			to the home directory.  Use |:pwd| to print the
			current directory on all systems.

:cd {path}		Change the current directory to {path}.
			If {path} is relative, it is searched for in the
			directories listed in |'cdpath'|.
			Does not change the meaning of an already opened file,
			because its full path name is remembered.  Files from
			the |arglist| may change though!
			On MS-DOS this also changes the active drive.
			To change to the directory of the current file: >
				:cd %:h
<
							*:cd-* *E186*
:cd -			Change to the previous current directory (before the
			previous ":cd {path}" command). {not in Vi}

							*:chd* *:chdir*
:chd[ir] [path]		Same as |:cd|.

							*:lc* *:lcd*
:lc[d] {path}		Like |:cd|, but only set the current directory for the
			current window.  The current directory for other
			windows is not changed. {not in Vi}

							*:lch* *:lchdir*
:lch[dir]		Same as |:lcd|. {not in Vi}

							*:pw* *:pwd* *E187*
:pw[d]			Print the current directory name.  {Vi: no pwd}
			Also see |getcwd()|.

So long as no |:lcd| command has been used, all windows share the same current
directory.  Using a command to jump to another window doesn't change anything
for the current directory.
When a |:lcd| command has been used for a window, the specified directory
becomes the current directory for that window.  Windows where the |:lcd|
command has not been used stick to the global current directory.  When jumping
to another window the current directory will become the last specified local
current directory.  If none was specified, the global current directory is
used.
When a |:cd| command is used, the current window will lose his local current
directory and will use the global current directory from now on.

After using |:cd| the full path name will be used for reading and writing
files.  On some networked file systems this may cause problems.  The result of
using the full path name is that the file names currently in use will remain
referring to the same file.  Example: If you have a file a:test and a
directory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the file
a:test and not write a:vim/test.  But if you do ":w test" the file a:vim/test
will be written, because you gave a new file name and did not refer to a
filename before the ":cd".

==============================================================================
5. The argument list				*argument-list* *arglist*

If you give more than one file name when starting Vim, this list is remembered
as the argument list.  You can jump to each file in this list.

Do not confuse this with the buffer list, which you can see with the
|:buffers| command.  The argument list was already present in Vi, the buffer
list is new in Vim.  A file name in the argument list will also be present in
the buffer list (unless it was deleted with ":bdel").

This subject is introduced in section |07.2| of the user manual.

There is one global argument list, which is used for all windows by default.
It is possible to create a new argument list local to a window, see
|:arglocal|.

You can use the argument list with the following commands, and with the
expression functions |argc()| and |argv()|.  These all work on the argument
list of the current window.

							*:ar* *:args*
:ar[gs]			Print the argument list, with the current file in
			square brackets.

:ar[gs] [++opt] [+cmd] {arglist}			*:args_f*
			Define {arglist} as the new argument list and edit
			the first one.  This fails when changes have been made
			and Vim does not want to |abandon| the current buffer.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

:ar[gs]! [++opt] [+cmd] {arglist}			*:args_f!*
			Define {arglist} as the new argument list and edit
			the first one.  Discard any changes to the current
			buffer.
			Also see |++opt| and |+cmd|.
			{Vi: no ++opt}

:[count]arge[dit][!] [++opt] [+cmd] {name}		*:arge* *:argedit*
			Add {name} to the argument list and edit it.
			When {name} already exists in the argument list, this
			entry is edited.
			This is like using |:argadd| and then |:edit|.
			Note that only one file name is allowed, and spaces
			inside the file name are allowed, like with |:edit|.
			[count] is used like with |:argadd|.
			[!] is required if the current file cannot be
			|abandon|ed.
			Also see |++opt| and |+cmd|.
			{not in Vi}

:[count]arga[dd] {name} ..			*:arga* *:argadd* *E479*
			Add the {name}s to the argument list.
			If [count] is omitted, the {name}s are added just
			after the current entry in the argument list.
			Otherwise they are added after the [count]'th file.
			If the argument list is "a b c", and "b" is the
			current argument, then these commands result in:
				command		new argument list ~
				:argadd x	a b x c
				:0argadd x	x a b c
				:1argadd x	a x b c
				:99argadd x	a b c x
			There is no check for duplicates, it is possible to
			add a file to the argument list twice.
			The currently edited file is not changed.
			{not in Vi} {not available when compiled without the
			|+listcmds| feature}
			Note: you can also use this method: >
				:args ## x
<			This will add the "x" item and sort the new list.

:argd[elete] {pattern} ..			*:argd* *:argdelete* *E480*
			Delete files from the argument list that match the
			{pattern}s.  {pattern} is used like a file pattern,
			see |file-pattern|.  "%" can be used to delete the
			current entry.
			This command keeps the currently edited file, also
			when it's deleted from the argument list.
			{not in Vi} {not available when compiled without the
			|+listcmds| feature}

:{range}argd[elete]	Delete the {range} files from the argument list.
			When the last number in the range is too high, up to
			the last argument is deleted.  Example: >
				:10,1000argdel
<			Deletes arguments 10 and further, keeping 1-9.
			{not in Vi} {not available when compiled without the
			|+listcmds| feature}

							*:argu* *:argument*
:[count]argu[ment] [count] [++opt] [+cmd]
			Edit file [count] in the argument list.  When [count]
			is omitted the current entry is used.  This fails
			when changes have been made and Vim does not want to
			|abandon| the current buffer.
			Also see |++opt| and |+cmd|.
			{not in Vi} {not available when compiled without the
			|+listcmds| feature}

:[count]argu[ment]! [count] [++opt] [+cmd]
			Edit file [count] in the argument list, discard any
			changes to the current buffer.  When [count] is
			omitted the current entry is used.
			Also see |++opt| and |+cmd|.
			{not in Vi} {not available when compiled without the
			|+listcmds| feature}

:[count]n[ext] [++opt] [+cmd]			*:n* *:ne* *:next* *E165* *E163*
			Edit [count] next file.  This fails when changes have
			been made and Vim does not want to |abandon| the
			current buffer.  Also see |++opt| and |+cmd|.  {Vi: no
			count or ++opt}.

:[count]n[ext]! [++opt] [+cmd]
			Edit [count] next file, discard any changes to the
			buffer.  Also see |++opt| and |+cmd|.  {Vi: no count
			or ++opt}.

:n[ext] [++opt] [+cmd] {arglist}			*:next_f*
			Same as |:args_f|.

:n[ext]! [++opt] [+cmd] {arglist}
			Same as |:args_f!|.

:[count]N[ext] [count] [++opt] [+cmd]			*:Next* *:N* *E164*
			Edit [count] previous file in argument list.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           