vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

editing.txt (78647B)


      1 *editing.txt*	For Vim version 9.2.  Last change: 2026 Aug 13
      2 
      3 
      4 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
      5 
      6 
      7 Editing files						*edit-files*
      8 
      9 1.  Introduction		|edit-intro|
     10 2.  Editing a file		|edit-a-file|
     11 3.  The argument list		|argument-list|
     12 4.  Writing			|writing|
     13 5.  Writing and quitting	|write-quit|
     14 6.  Dialogs			|edit-dialogs|
     15 7.  The current directory	|current-directory|
     16 8.  Editing binary files	|edit-binary|
     17 9.  Encryption			|encryption|
     18 10. Timestamps			|timestamps|
     19 11. File Searching		|file-searching|
     20 
     21 ==============================================================================
     22 1. Introduction						*edit-intro*
     23 
     24 Editing a file with Vim means:
     25 
     26 1. reading the file into a buffer
     27 2. changing the buffer with editor commands
     28 3. writing the buffer into a file
     29 
     30 							*current-file*
     31 As long as you don't write the buffer, the original file remains unchanged.
     32 If you start editing a file (read a file into the buffer), the file name is
     33 remembered as the "current file name".  This is also known as the name of the
     34 current buffer.  It can be used with "%" on the command line |:_%|.
     35 
     36 							*alternate-file*
     37 If there already was a current file name, then that one becomes the alternate
     38 file name.  It can be used with "#" on the command line |:_#| and you can use
     39 the |CTRL-^| command to toggle between the current and the alternate file.
     40 However, the alternate file name is not changed when |:keepalt| is used.
     41 An alternate file name is remembered for each window.
     42 
     43 							*:keepa* *:keepalt*
     44 :keepa[lt] {cmd}	Execute {cmd} while keeping the current alternate file
     45 			name.  Note that commands invoked indirectly (e.g.,
     46 			with a function) may still set the alternate file
     47 			name.
     48 
     49 All file names are remembered in the buffer list.  When you enter a file name,
     50 for editing (e.g., with ":e filename") or writing (e.g., with ":w filename"),
     51 the file name is added to the list.  You can use the buffer list to remember
     52 which files you edited and to quickly switch from one file to another (e.g.,
     53 to copy text) with the |CTRL-^| command.  First type the number of the file
     54 and then hit CTRL-^.
     55 
     56 
     57 CTRL-G		or				*CTRL-G* *:f* *:fi* *:file*
     58 :f[ile]			Prints the current file name (as typed, unless ":cd"
     59 			was used), the cursor position (unless the 'ruler'
     60 			option is set), and the file status (readonly,
     61 			modified, read errors, new file).  See the 'shortmess'
     62 			option about how to make this message shorter.
     63 
     64 :f[ile]!		like |:file|, but don't truncate the name even when
     65 			'shortmess' indicates this.
     66 
     67 {count}CTRL-G		Like CTRL-G, but prints the current file name with
     68 			full path.  If the count is higher than 1 the current
     69 			buffer number is also given.
     70 
     71 					*g_CTRL-G* *word-count* *byte-count*
     72 g CTRL-G		Prints the current position of the cursor in five
     73 			ways: Column, Line, Word, Character and Byte.  If the
     74 			number of Characters and Bytes is the same then the
     75 			Character position is omitted.
     76 
     77 			If there are characters in the line that take more
     78 			than one position on the screen (<Tab> or special
     79 			character), or characters using more than one byte per
     80 			column (characters above 0x7F when 'encoding' is
     81 			utf-8), both the byte column and the screen column are
     82 			shown, separated by a dash.
     83 
     84 			Also see the 'ruler' option and the |wordcount()|
     85 			function.
     86 
     87 							*v_g_CTRL-G*
     88 {Visual}g CTRL-G	Similar to "g CTRL-G", but Word, Character, Line, and
     89 			Byte counts for the visually selected region are
     90 			displayed.
     91 			In Blockwise mode, Column count is also shown.  (For
     92 			{Visual} see |Visual-mode|.)
     93 
     94 							*:file_f*
     95 :f[ile][!] {name}	Sets the current file name to {name}.  The optional !
     96 			avoids truncating the message, as with |:file|.
     97 			If the buffer did have a name, that name becomes the
     98 			|alternate-file| name.  An unlisted buffer is created
     99 			to hold the old name.
    100 							*:0file*
    101 :0f[ile][!]		Remove the name of the current buffer.  The optional !
    102 			avoids truncating the message, as with |:file|.
    103 
    104 :buffers
    105 :files
    106 :ls			List all the currently known file names.  See
    107 			|windows.txt| |:files| |:buffers| |:ls|.
    108 
    109 Vim will remember the full path name of a file name that you enter.  In most
    110 cases when the file name is displayed only the name you typed is shown, but
    111 the full path name is being used if you used the ":cd" command |:cd|.
    112 
    113 							*home-replace*
    114 If the environment variable $HOME is set, and the file name starts with that
    115 string, it is often displayed with HOME replaced with "~".  This was done to
    116 keep file names short.  When reading or writing files the full name is still
    117 used, the "~" is only used when displaying file names.  When replacing the
    118 file name would result in just "~", "~/" is used instead (to avoid confusion
    119 between options set to $HOME with 'backupext' set to "~").
    120 
    121 When writing the buffer, the default is to use the current file name.  Thus
    122 when you give the "ZZ" or ":wq" command, the original file will be
    123 overwritten.  If you do not want this, the buffer can be written into another
    124 file by giving a file name argument to the ":write" command.  For example: >
    125 
    126 	vim testfile
    127 	[change the buffer with editor commands]
    128 	:w newfile
    129 	:q
    130 
    131 This will create a file "newfile", that is a modified copy of "testfile".
    132 The file "testfile" will remain unchanged.  Anyway, if the 'backup' option is
    133 set, Vim renames or copies the original file before it will be overwritten.
    134 You can use this file if you discover that you need the original file.  See
    135 also the 'patchmode' option.  The name of the backup file is normally the same
    136 as the original file with 'backupext' appended.  The default "~" is a bit
    137 strange to avoid accidentally overwriting existing files.  If you prefer
    138 ".bak" change the 'backupext' option.  Extra dots are replaced with '_' on
    139 MS-Windows machines, when Vim has detected that an MS-DOS-like filesystem is
    140 being used, or when the 'shortname' option is on.
    141 The backup file can be placed in another directory by setting 'backupdir'.
    142 
    143 							*auto-shortname*
    144 Technical: On the Amiga you can use 30 characters for a file name.  But on an
    145 	   MS-DOS-compatible filesystem only 8 plus 3 characters are
    146 	   available.  Vim tries to detect the type of filesystem when it is
    147 	   creating the .swp file.  If an MS-DOS-like filesystem is suspected,
    148 	   a flag is set that has the same effect as setting the 'shortname'
    149 	   option.  This flag will be reset as soon as you start editing a
    150 	   new file.  The flag will be used when making the file name for the
    151 	   ".swp" and ".~" files for the current file.  But when you are
    152 	   editing a file in a normal filesystem and write to an MS-DOS-like
    153 	   filesystem the flag will not have been set.  In that case the
    154 	   creation of the ".~" file may fail and you will get an error
    155 	   message.  Use the 'shortname' option in this case.
    156 
    157 When you started editing without giving a file name, "No File" is displayed in
    158 messages.  If the ":write" command is used with a file name argument, the file
    159 name for the current file is set to that file name.  This only happens when
    160 the 'F' flag is included in 'cpoptions' (by default it is included) |cpo-F|.
    161 This is useful when entering text in an empty buffer and then writing it to a
    162 file.  If 'cpoptions' contains the 'f' flag (by default it is NOT included)
    163 |cpo-f| the file name is set for the ":read file" command.  This is useful
    164 when starting Vim without an argument and then doing ":read file" to start
    165 editing a file.
    166 When the file name was set and 'filetype' is empty the filetype detection
    167 autocommands will be triggered.
    168 							*not-edited*
    169 Because the file name was set without really starting to edit that file, you
    170 are protected from overwriting that file.  This is done by setting the
    171 "notedited" flag.  You can see if this flag is set with the CTRL-G or ":file"
    172 command.  It will include "[Not edited]" when the "notedited" flag is set.
    173 When writing the buffer to the current file name (with ":w!"), the "notedited"
    174 flag is reset.
    175 
    176 							*abandon*
    177 Vim remembers whether you have changed the buffer.  You are protected from
    178 losing the changes you made.  If you try to quit without writing, or want to
    179 start editing another file, Vim will refuse this.  In order to overrule this
    180 protection, add a '!' to the command.  The changes will then be lost.  For
    181 example: ":q" will not work if the buffer was changed, but ":q!" will.  To see
    182 whether the buffer was changed use the "CTRL-G" command.  The message includes
    183 the string "[Modified]" if the buffer has been changed, or "+" if the 'm' flag
    184 is in 'shortmess'.
    185 
    186 If you want to automatically save the changes without asking, switch on the
    187 'autowriteall' option.  'autowrite' is the associated Vi-compatible option
    188 that does not work for all commands.
    189 
    190 If you want to keep the changed buffer without saving it, switch on the
    191 'hidden' option.  See |hidden-buffer|.  Some commands work like this even when
    192 'hidden' is not set, check the help for the command.
    193 
    194 ==============================================================================
    195 2. Editing a file					*edit-a-file*
    196 
    197 							*:e* *:edit* *reload*
    198 :e[dit] [++opt] [+cmd]	Edit the current file.  This is useful to re-edit the
    199 			current file, when it has been changed outside of Vim.
    200 			This fails when changes have been made to the current
    201 			buffer and 'autowriteall' isn't set or the file can't
    202 			be written.
    203 			Also see |++opt| and |+cmd|.
    204 
    205 							*:edit!* *discard*
    206 :e[dit]! [++opt] [+cmd]
    207 			Edit the current file always.  Discard any changes to
    208 			the current buffer.  This is useful if you want to
    209 			start all over again.
    210 			Also see |++opt| and |+cmd|.
    211 
    212 							*:edit_f*
    213 :e[dit] [++opt] [+cmd] {file}
    214 			Edit {file}.
    215 			This fails when changes have been made to the current
    216 			buffer, unless 'hidden' is set or 'autowriteall' is
    217 			set and the file can be written.
    218 			Also see |++opt| and |+cmd|.
    219 
    220 							*:edit!_f*
    221 :e[dit]! [++opt] [+cmd] {file}
    222 			Edit {file} always.  Discard any changes to the
    223 			current buffer.
    224 			Also see |++opt| and |+cmd|.
    225 							*:edit_#* *:e#*
    226 :e[dit] [++opt] [+cmd] #[count]
    227 			Edit the [count]th buffer (as shown by |:files|).
    228 			This command does the same as [count] CTRL-^.  But ":e
    229 			#" doesn't work if the alternate buffer doesn't have a
    230 			file name, while CTRL-^ still works then.
    231 			Also see |++opt| and |+cmd|.
    232 
    233 							*:ene* *:enew*
    234 :ene[w]			Edit a new, unnamed buffer.  This fails when changes
    235 			have been made to the current buffer, unless 'hidden'
    236 			is set or 'autowriteall' is set and the file can be
    237 			written.
    238 			If 'fileformats' is not empty, the first format given
    239 			will be used for the new buffer.  If 'fileformats' is
    240 			empty, the 'fileformat' of the current buffer is used.
    241 
    242 							*:ene!* *:enew!*
    243 :ene[w]!		Edit a new, unnamed buffer.  Discard any changes to
    244 			the current buffer.
    245 			Set 'fileformat' like |:enew|.
    246 
    247 							*:fin* *:find*
    248 :fin[d][!] [++opt] [+cmd] {file}
    249 			Find {file} in 'path' and then |:edit| it.
    250 			See also: 'findfunc'.
    251 
    252 :{count}fin[d][!] [++opt] [+cmd] {file}
    253 			Just like ":find", but use the {count} match in
    254 			'path'.  Thus ":2find file" will find the second
    255 			"file" found in 'path'.  When there are fewer matches
    256 			for the file in 'path' than asked for, you get an
    257 			error message.
    258 
    259 							*:ex*
    260 :ex [++opt] [+cmd] [file]
    261 			Same as |:edit|.
    262 
    263 							*:vi* *:visual*
    264 :vi[sual][!] [++opt] [+cmd] [file]
    265 			When used in Ex mode: Leave |Ex-mode|, go back to
    266 			Normal mode.  Otherwise same as |:edit|.
    267 
    268 							*:vie* *:view*
    269 :vie[w][!] [++opt] [+cmd] file
    270 			When used in Ex mode: Leave |Ex-mode|, go back to
    271 			Normal mode.  Otherwise same as |:edit|, but set
    272 			'readonly' option for this buffer.
    273 
    274 							*CTRL-^* *CTRL-6*
    275 CTRL-^			Edit the alternate file.  Mostly the alternate file is
    276 			the previously edited file.  This is a quick way to
    277 			toggle between two files.  It is equivalent to ":e #",
    278 			except that it also works when there is no file name.
    279 
    280 			If the 'autowrite' or 'autowriteall' option is on and
    281 			the buffer was changed, write it.
    282 			Mostly the ^ character is positioned on the 6 key,
    283 			pressing CTRL and 6 then gets you what we call CTRL-^.
    284 			But on some non-US keyboards CTRL-^ is produced in
    285 			another way.
    286 
    287 {count}CTRL-^		Edit [count]th file in the buffer list (equivalent to
    288 			":e #[count]").  This is a quick way to switch between
    289 			files.
    290 			See |CTRL-^| above for further details.
    291 
    292 [count]]f						*]f* *[f*
    293 [count][f		Same as "gf".  Deprecated.
    294 
    295 							*gf* *E446* *E447*
    296 [count]gf		Edit the file whose name is under or after the cursor.
    297 			Mnemonic: "goto file".
    298 			Uses the 'isfname' option to find out which characters
    299 			are supposed to be in a file name.  Trailing
    300 			punctuation characters ".,:;!" are ignored.  Escaped
    301 			spaces "\ " are reduced to a single space.
    302 			Uses the 'path' option as a list of directory names to
    303 			look for the file.  See the 'path' option for details
    304 			about relative directories and wildcards.
    305 			Uses the 'suffixesadd' option to check for file names
    306 			with a suffix added.
    307 			If the file can't be found, 'includeexpr' is used to
    308 			modify the name and another attempt is done.
    309 			If a [count] is given, the count'th file that is found
    310 			in the 'path' is edited.
    311 			This command fails if Vim refuses to |abandon| the
    312 			current file.
    313 			If you want to edit the file in a new window use
    314 			|CTRL-W_CTRL-F|.
    315 			If you do want to edit a new file, use: >
    316 				:e <cfile>
    317 <			To make gf always work like that: >
    318 				:map gf :e <cfile><CR>
    319 <			If the name is a hypertext link, that looks like
    320 			"type://machine/path", you need the |netrw| plugin.
    321 			For Unix the '~' character is expanded, like in
    322 			"~user/file".  Environment variables are expanded too
    323 			|expand-env|.
    324 
    325 							*v_gf*
    326 {Visual}[count]gf	Same as "gf", but the highlighted text is used as the
    327 			name of the file to edit.  'isfname' is ignored.
    328 			Leading blanks are skipped, otherwise all blanks and
    329 			special characters are included in the file name.
    330 			(For {Visual} see |Visual-mode|.)
    331 
    332 							*gF*
    333 [count]gF		Same as "gf", except if a number follows the file
    334 			name, then the cursor is positioned on that line in
    335 			the file.
    336 			The file name and the number must be separated by a
    337 			non-filename (see 'isfname') and non-numeric
    338 			character.  " line " is also recognized, like it is
    339 			used in the output of `:verbose command UserCmd`
    340 			White space between the filename, the separator and
    341 			the number is ignored.
    342 			Examples:
    343 				eval.c:10 ~
    344 				eval.c @ 20 ~
    345 				eval.c (30) ~
    346 				eval.c 40 ~
    347 				eval.c line 50 ~
    348 
    349 							*v_gF*
    350 {Visual}[count]gF	Same as "v_gf", but if a colon and a number appear
    351 			immediately after the end of the selected text,
    352 			then the cursor is positioned on that line in the
    353 			file.  Unlike |gF|, only a colon is recognized as
    354 			separator.
    355 
    356 These commands are used to start editing a single file.  This means that the
    357 file is read into the buffer and the current file name is set.  The file that
    358 is opened depends on the current directory, see |:cd|.
    359 
    360 See |read-messages| for an explanation of the message that is given after the
    361 file has been read.
    362 
    363 You can use the ":e!" command if you messed up the buffer and want to start
    364 all over again.  The ":e" command is only useful if you have changed the
    365 current file name.
    366 
    367 							*:filename* *{file}*
    368 Besides the things mentioned here, more special items for where a filename is
    369 expected are mentioned at |cmdline-special|.
    370 
    371 Note for systems other than Unix: When using a command that accepts a single
    372 file name (like ":edit file") spaces in the file name are allowed, but
    373 trailing spaces are ignored.  This is useful on systems that regularly embed
    374 spaces in file names (like MS-Windows and the Amiga).  Example: The command
    375 ":e   Long File Name " will edit the file "Long File Name".  When using a
    376 command that accepts more than one file name (like ":next file1 file2")
    377 embedded spaces must be escaped with a backslash.
    378 
    379 						*wildcard* *wildcards*
    380 Wildcards in {file} are expanded, but as with file completion, 'wildignore'
    381 and 'suffixes' apply.  Which wildcards are supported depends on the system.
    382 These are the common ones:
    383 	?	matches one character
    384 	*	matches anything, including nothing
    385 	**	matches anything, including nothing, recurses into directories
    386 	[abc]	match 'a', 'b' or 'c'
    387 
    388 To avoid the special meaning of the wildcards prepend a backslash.  However,
    389 on MS-Windows the backslash is a path separator and "path\[abc]" is still seen
    390 as a wildcard when "[" is in the 'isfname' option.  A simple way to avoid this
    391 is to use "path\[[]abc]", this matches the file "path\[abc]".
    392 
    393 					*starstar-wildcard*
    394 Expanding "**" is possible on Unix, Win32, macOS and a few other systems (but
    395 it may depend on your 'shell' setting on Unix and macOS.  It's known to work
    396 correctly for zsh; for bash this requires at least bash version >= 4.X).
    397 This allows searching a directory tree.  This goes up to 100 directories deep.
    398 Note there are some commands where this works slightly differently, see
    399 |file-searching|.
    400 Example: >
    401 	:n **/*.txt
    402 Finds files:
    403 	aaa.txt ~
    404 	subdir/bbb.txt ~
    405 	a/b/c/d/ccc.txt ~
    406 When non-wildcard characters are used right before or after "**" these are
    407 only matched in the top directory.  They are not used for directories further
    408 down in the tree.  For example: >
    409 	:n /usr/inc**/types.h
    410 Finds files:
    411 	/usr/include/types.h ~
    412 	/usr/include/sys/types.h ~
    413 	/usr/inc/old/types.h ~
    414 Note that the path with "/sys" is included because it does not need to match
    415 "/inc".  Thus it's like matching "/usr/inc*/*/*...", not
    416 "/usr/inc*/inc*/inc*".
    417 
    418 					*backtick-expansion* *`-expansion*
    419 On Unix and a few other systems you can also use backticks for the file name
    420 argument, for example: >
    421 	:next `find . -name ver\\*.c -print`
    422 	:view `ls -t *.patch  \| head -n1`
    423 Vim will run the command in backticks using the 'shell' and use the standard
    424 output as argument for the given Vim command (error messages from the shell
    425 command will be discarded).
    426 To see what shell command Vim is running, set the 'verbose' option to 4.  When
    427 the shell command returns a non-zero exit code, an error message will be
    428 displayed and the Vim command will be aborted.  To avoid this make the shell
    429 always return zero like so: >
    430        :next `find . -name ver\\*.c -print \|\| true`
    431 
    432 The backslashes before the star are required to prevent the shell from
    433 expanding "ver*.c" prior to execution of the find program.  The backslash
    434 before the shell pipe symbol "|" prevents Vim from parsing it as command
    435 termination.
    436 This also works for most other systems, with the restriction that the
    437 backticks must be around the whole item.  It is not possible to have text
    438 directly before the first or just after the last backtick.
    439 
    440 						*`=* *E1083*
    441 You can have the backticks expanded as a Vim expression, instead of as an
    442 external command, by putting an equal sign right after the first backtick,
    443 e.g.: >
    444 	:e `=tempname()`
    445 The expression can contain just about anything, thus this can also be used to
    446 avoid the special meaning of '"', '|', '%' and '#'.  However, 'wildignore'
    447 does apply like to other wildcards.
    448 
    449 Environment variables in the expression are expanded when evaluating the
    450 expression, thus this works: >
    451 	:e `=$HOME .. '/.vimrc'`
    452 This uses $HOME inside a string and it will be used literally, most likely not
    453 what you intended: >
    454 	:e `='$HOME' .. '/.vimrc'`
    455 
    456 If the expression returns a string then names are to be separated with line
    457 breaks.  When the result is a |List| then each item is used as a name.  Line
    458 breaks also separate names.
    459 Note that such expressions are only supported in places where a filename is
    460 expected as an argument to an Ex-command.
    461 
    462 							*++opt* *[++opt]*
    463 The [++opt] argument can be used to force the value of 'fileformat',
    464 'fileencoding' or 'binary' to a value for one command, and to specify the
    465 behavior for bad characters.  The form is: >
    466 	++{optname}
    467 Or: >
    468 	++{optname}={value}
    469 
    470 Where {optname} is one of:	    *++ff* *++enc* *++bin* *++nobin* *++edit*
    471     ff     or  fileformat   overrides 'fileformat'
    472     enc    or  encoding	    overrides 'fileencoding'
    473     bin    or  binary	    sets 'binary'
    474     nobin  or  nobinary	    resets 'binary'
    475     bad			    specifies behavior for bad characters
    476     edit		    for |:read| only: keep option values as if editing
    477 			    a file
    478 
    479 {value} cannot contain white space.  It can be any valid value for these
    480 options.  Examples: >
    481 	:e ++ff=unix
    482 This edits the same file again with 'fileformat' set to "unix". >
    483 
    484 	:w ++enc=latin1 newfile
    485 This writes the current buffer to "newfile" in latin1 format.
    486 
    487 The message given when writing a file will show "[converted]" when
    488 'fileencoding' or the value specified with ++enc differs from 'encoding'.
    489 
    490 There may be several ++opt arguments, separated by white space.  They must all
    491 appear before any |+cmd| argument.
    492 
    493 								*++bad*
    494 The argument of "++bad=" specifies what happens with characters that can't be
    495 converted and illegal bytes.  It can be one of three things:
    496     ++bad=X      A single-byte character that replaces each bad character.
    497     ++bad=keep   Keep bad characters without conversion.  Note that this may
    498 		 result in illegal bytes in your text!
    499     ++bad=drop   Remove the bad characters.
    500 
    501 The default is like "++bad=?": Replace each bad character with a question
    502 mark.  In some places an inverted question mark is used (0xBF).
    503 
    504 Note that not all commands use the ++bad argument, even though they do not
    505 give an error when you add it.  E.g. |:write|.
    506 
    507 Note that when reading, the 'fileformat' and 'fileencoding' options will be
    508 set to the used format.  When writing this doesn't happen, thus a next write
    509 will use the old value of the option.  Same for the 'binary' option.
    510 
    511 
    512 							*+cmd* *[+cmd]*
    513 The [+cmd] argument can be used to position the cursor in the newly opened
    514 file, or execute any other command:
    515 	+		Start at the last line.
    516 	+{num}		Start at line {num}.
    517 	+/{pat}		Start at first line containing {pat}.
    518 	+{command}	Execute {command} after opening the new file.
    519 			{command} is any Ex command.
    520 To include a white space in the {pat} or {command}, precede it with a
    521 backslash.  Double the number of backslashes. >
    522 	:edit  +/The\ book	     file
    523 	:edit  +/dir\ dirname\\      file
    524 	:edit  +set\ dir=c:\\\\temp  file
    525 Note that in the last example the number of backslashes is halved twice: Once
    526 for the "+cmd" argument and once for the ":set" command.
    527 
    528 							*file-formats*
    529 The 'fileformat' option sets the <EOL> style for a file:
    530 'fileformat'    characters	   name				~
    531   "dos"		<CR><NL> or <NL>   DOS format		*DOS-format*
    532   "unix"	<NL>		   Unix format		*Unix-format*
    533   "mac"		<CR>		   Mac format		*Mac-format*
    534 Previously 'textmode' was used.  It is obsolete now.
    535 
    536 When reading a file, the mentioned characters are interpreted as the <EOL>.
    537 In DOS format (default for Win32), <CR><NL> and <NL> are both interpreted as
    538 the <EOL>.  Note that when writing the file in DOS format, <CR> characters
    539 will be added for each single <NL>.  Also see |file-read|.
    540 
    541 When writing a file, the mentioned characters are used for <EOL>.  For DOS
    542 format <CR><NL> is used.  Also see |DOS-format-write|.
    543 
    544 You can read a file in DOS format and write it in Unix format.  This will
    545 replace all <CR><NL> pairs by <NL> (assuming 'fileformats' includes "dos"): >
    546 	:e file
    547 	:set fileformat=unix
    548 	:w
    549 If you read a file in Unix format and write with DOS format, all <NL>
    550 characters will be replaced with <CR><NL> (assuming 'fileformats' includes
    551 "unix"): >
    552 	:e file
    553 	:set fileformat=dos
    554 	:w
    555 
    556 If you start editing a new file and the 'fileformats' option is not empty
    557 (which is the default), Vim will try to detect whether the lines in the file
    558 are separated by the specified formats.  When set to "unix,dos", Vim will
    559 check for lines with a single <NL> (as used on Unix and Amiga) or by a <CR>
    560 <NL> pair (MS-Windows).  Only when ALL lines end in <CR><NL>, 'fileformat' is
    561 set to "dos", otherwise it is set to "unix".  When 'fileformats' includes
    562 "mac", and no <NL> characters are found in the file, 'fileformat' is set to
    563 "mac".
    564 
    565 If the 'fileformat' option is set to "dos" on non-MS-Windows systems the
    566 message "[dos format]" is shown to remind you that something unusual is
    567 happening.  On MS-Windows systems you get the message "[unix format]" if
    568 'fileformat' is set to "unix".  On all systems but the Macintosh you get the
    569 message "[mac format]" if 'fileformat' is set to "mac".
    570 
    571 If the 'fileformats' option is empty and DOS format is used, but while reading
    572 a file some lines did not end in <CR><NL>, "[CR missing]" will be included in
    573 the file message.
    574 If the 'fileformats' option is empty and Mac format is used, but while reading
    575 a file a <NL> was found, "[NL missing]" will be included in the file message.
    576 
    577 If the new file does not exist, the 'fileformat' of the current buffer is used
    578 when 'fileformats' is empty.  Otherwise the first format from 'fileformats' is
    579 used for the new file.
    580 
    581 Before editing binary, executable or Vim script files you should set the
    582 'binary' option.  A simple way to do this is by starting Vim with the "-b"
    583 option.  This will avoid the use of 'fileformat'.  Without this you risk that
    584 single <NL> characters are unexpectedly replaced with <CR><NL>.
    585 
    586 You can encrypt files that are written by setting the 'key' option.  This
    587 provides some security against others reading your files. |encryption|
    588 
    589 END OF LINE AND END OF FILE				*eol-and-eof*
    590 
    591 Vim has several options to control the file format:
    592 	'fileformat'	the <EOL> style: Unix, DOS, Mac
    593 	'endofline'	whether the last line ends with a <EOL>
    594 	'endoffile'	whether the file ends with a CTRL-Z
    595 	'fixendofline'	whether to fix eol and eof
    596 
    597 The first three values are normally detected automatically when reading the
    598 file and are used when writing the text to a file.  While editing the buffer
    599 it looks like every line has a line ending and the CTRL-Z isn't there (an
    600 exception is when 'binary' is set, it works differently then).
    601 
    602 The 'fixendofline' option can be used to choose what to write.  You can also
    603 change the option values to write the file differently than how it was read.
    604 
    605 Here are some examples how to use them.
    606 
    607 If you want files in Unix format (every line NL terminated): >
    608 	setl ff=unix fixeol
    609 You should probably do this on any Unix-like system.  Also modern MS-Windows
    610 systems tend to work well with this.  It is recommended to always use this
    611 format for Vim scripts.
    612 
    613 If you want to use an old MS-DOS file in a modern environment, fixing line
    614 endings and dropping CTRL-Z, but keeping the <CR><NL> style <EOL>: >
    615 	setl ff=dos fixeol
    616 This is useful for many MS-Windows programs, they regularly expect the
    617 <CR><NL> line endings.
    618 
    619 If you want to drop the final <EOL> and add a final CTRL-Z (e.g. for an old
    620 system like CP/M): >
    621 	setl ff=dos nofixeol noeol eof
    622 
    623 If you want to preserve the fileformat exactly as-is, including any final
    624 <EOL> and final CTRL-Z: >
    625 	setl nofixeol
    626 
    627 ==============================================================================
    628 3. The argument list				*argument-list* *arglist*
    629 
    630 If you give more than one file name when starting Vim, this list is remembered
    631 as the argument list.  You can jump to each file in this list.
    632 
    633 Do not confuse this with the buffer list, which you can see with the
    634 |:buffers| command.  The argument list was already present in Vi, the buffer
    635 list is new in Vim.  Every file name in the argument list will also be present
    636 in the buffer list (unless it was deleted with |:bdel| or |:bwipe|).  But it's
    637 common that names in the buffer list are not in the argument list.
    638 
    639 This subject is introduced in section |07.2| of the user manual.
    640 
    641 There is one global argument list, which is used for all windows by default.
    642 It is possible to create a new argument list local to a window, see
    643 |:arglocal|.
    644 
    645 You can use the argument list with the following commands, and with the
    646 expression functions |argc()| and |argv()|.  These all work on the argument
    647 list of the current window.
    648 
    649 							*:ar* *:arg* *:args*
    650 :ar[gs]			Print the argument list, with the current file in
    651 			square brackets.
    652 
    653 :ar[gs] [++opt] [+cmd] {arglist}			*:args_f*
    654 			Define {arglist} as the new argument list and edit
    655 			the first one.  This fails when changes have been made
    656 			and Vim does not want to |abandon| the current buffer.
    657 			Also see |++opt| and |+cmd|.
    658 
    659 :ar[gs]! [++opt] [+cmd] {arglist}			*:args_f!*
    660 			Define {arglist} as the new argument list and edit
    661 			the first one.  Discard any changes to the current
    662 			buffer.
    663 			Also see |++opt| and |+cmd|.
    664 
    665 :[count]arge[dit][!] [++opt] [+cmd] {name} ...		*:arge* *:argedit*
    666 			Add {name}s to the argument list and edit it.
    667 			There is no check for duplicates, it is possible to
    668 			add a file to the argument list twice |:argded|.
    669 			This is like using |:argadd| and then |:edit| (with
    670 			the small exception that |:edit| does not change the
    671 			argument list, so the argument list pointer isn't
    672 			changed).
    673 			Spaces in filenames have to be escaped with "\".
    674 			[count] is used like with |:argadd|.
    675 			If the current file cannot be |abandon|ed {name}s will
    676 			still be added to the argument list, but won't be
    677 			edited.  No check for duplicates is done.
    678 			Also see |++opt| and |+cmd|.
    679 
    680 :[count]arga[dd] {name} ...			*:arga* *:argadd* *E479*
    681 :[count]arga[dd]						*E1156*
    682 			Add the {name}s to the argument list.  When {name} is
    683 			omitted add the current buffer name to the argument
    684 			list.
    685 			If [count] is omitted, the {name}s are added just
    686 			after the current entry in the argument list.
    687 			Otherwise they are added after the [count]'th file.
    688 			If the argument list is "a b c", and "b" is the
    689 			current argument, then these commands result in:
    690 				command		new argument list ~
    691 				:argadd x	a  [b]  x  c
    692 				:0argadd x	x   a  [b] c
    693 				:1argadd x	a   x  [b] c
    694 				:$argadd x	a  [b]  c  x
    695 			And after the last one:
    696 				:+2argadd y	a  [b]  c  x  y
    697 			There is no check for duplicates, it is possible to
    698 			add a file to the argument list twice.  You can use
    699 			|:argdedupe| to fix it afterwards: >
    700 				:argadd *.txt | argdedupe
    701 <			The currently edited file is not changed.
    702 			Note: you can also use this method: >
    703 				:args ## x
    704 <			This will add the "x" item and sort the new list.
    705 
    706 :argded[upe]					*:argded* *:argdedupe*
    707 			Remove duplicate filenames from the argument list.
    708 			If your current file is a duplicate, your current file
    709 			will change to the original file index.
    710 
    711 :argd[elete] {pattern} ...		*:argd* *:argdelete* *E480* *E610*
    712 			Delete files from the argument list that match the
    713 			{pattern}s.  {pattern} is used like a file pattern,
    714 			see |file-pattern|.  "%" can be used to delete the
    715 			current entry.
    716 			This command keeps the currently edited file, also
    717 			when it's deleted from the argument list.
    718 			Example: >
    719 				:argdel *.obj
    720 
    721 :[range]argd[elete]	Delete the [range] files from the argument list.
    722 			Example: >
    723 				:10,$argdel
    724 <			Deletes arguments 10 and further, keeping 1-9. >
    725 				:$argd
    726 <			Deletes just the last one. >
    727 				:argd
    728 				:.argd
    729 <			Deletes the current argument. >
    730 				:%argd
    731 <			Removes all the files from the arglist.
    732 			When the last number in the range is too high, up to
    733 			the last argument is deleted.
    734 
    735 							*:argu* *:argument*
    736 :[count]argu[ment] [count] [++opt] [+cmd]
    737 			Edit file [count] in the argument list.  When [count]
    738 			is omitted the current entry is used.  This fails
    739 			when changes have been made and Vim does not want to
    740 			|abandon| the current buffer.
    741 			Also see |++opt| and |+cmd|.
    742 
    743 :[count]argu[ment]! [count] [++opt] [+cmd]
    744 			Edit file [count] in the argument list, discard any
    745 			changes to the current buffer.  When [count] is
    746 			omitted the current entry is used.
    747 			Also see |++opt| and |+cmd|.
    748 
    749 :[count]n[ext] [++opt] [+cmd]			*:n* *:ne* *:next* *E165* *E163*
    750 			Edit [count] next file.  This fails when changes have
    751 			been made and Vim does not want to |abandon| the
    752 			current buffer.  Also see |++opt| and |+cmd|.
    753 
    754 :[count]n[ext]! [++opt] [+cmd]
    755 			Edit [count] next file, discard any changes to the
    756 			buffer.  Also see |++opt| and |+cmd|.
    757 
    758 :n[ext] [++opt] [+cmd] {arglist}			*:next_f*
    759 			Same as |:args_f|.
    760 
    761 :n[ext]! [++opt] [+cmd] {arglist}
    762 			Same as |:args_f!|.
    763 
    764 :[count]N[ext] [count] [++opt] [+cmd]			*:Next* *:N* *E164*
    765 			Edit [count] previous file in argument list.  This
    766 			fails when changes have been made and Vim does not
    767 			want to |abandon| the current buffer.
    768 			Also see |++opt| and |+cmd|.
    769 
    770 :[count]N[ext]! [count] [++opt] [+cmd]
    771 			Edit [count] previous file in argument list.  Discard
    772 			any changes to the buffer.  Also see |++opt| and
    773 			|+cmd|.
    774 
    775 :[count]prev[ious] [count] [++opt] [+cmd]		*:prev* *:previous*
    776 			Same as :Next.  Also see |++opt| and |+cmd|.
    777 
    778 							*:rew* *:rewind*
    779 :rew[ind] [++opt] [+cmd]
    780 			Start editing the first file in the argument list.
    781 			This fails when changes have been made and Vim does
    782 			not want to |abandon| the current buffer.
    783 			Also see |++opt| and |+cmd|.
    784 
    785 :rew[ind]! [++opt] [+cmd]
    786 			Start editing the first file in the argument list.
    787 			Discard any changes to the buffer.  Also see |++opt|
    788 			and |+cmd|.
    789 
    790 							*:fir* *:first*
    791 :fir[st][!] [++opt] [+cmd]
    792 			Other name for ":rewind".
    793 
    794 							*:la* *:last*
    795 :la[st] [++opt] [+cmd]
    796 			Start editing the last file in the argument list.
    797 			This fails when changes have been made and Vim does
    798 			not want to |abandon| the current buffer.
    799 			Also see |++opt| and |+cmd|.
    800 
    801 :la[st]! [++opt] [+cmd]
    802 			Start editing the last file in the argument list.
    803 			Discard any changes to the buffer.  Also see |++opt|
    804 			and |+cmd|.
    805 
    806 							*:wn* *:wnext*
    807 :[count]wn[ext] [++opt]
    808 			Write current file and start editing the [count]
    809 			next file.  Also see |++opt| and |+cmd|.
    810 
    811 :[count]wn[ext] [++opt] {file}
    812 			Write current file to {file} and start editing the
    813 			[count] next file, unless {file} already exists and
    814 			the 'writeany' option is off.  Also see |++opt| and
    815 			|+cmd|.
    816 
    817 :[count]wn[ext]! [++opt] {file}
    818 			Write current file to {file} and start editing the
    819 			[count] next file.  Also see |++opt| and |+cmd|.
    820 
    821 :[count]wN[ext][!] [++opt] [file]		*:wN* *:wNext*
    822 :[count]wp[revious][!] [++opt] [file]		*:wp* *:wprevious*
    823 			Same as :wnext, but go to previous file instead of
    824 			next.
    825 
    826 The [count] in the commands above defaults to one.  For some commands it is
    827 possible to use two counts.  The last one (rightmost one) is used.
    828 
    829 If no [+cmd] argument is present, the cursor is positioned at the last known
    830 cursor position for the file.  If 'startofline' is set, the cursor will be
    831 positioned at the first non-blank in the line, otherwise the last know column
    832 is used.  If there is no last known cursor position the cursor will be in the
    833 first line (the last line in Ex mode).
    834 
    835 							*{arglist}*
    836 The wildcards in the argument list are expanded and the file names are sorted.
    837 Thus you can use the command "vim *.c" to edit all the C files.  From within
    838 Vim the command ":n *.c" does the same.
    839 
    840 White space is used to separate file names.  Put a backslash before a space or
    841 tab to include it in a file name.  E.g., to edit the single file "foo bar": >
    842 	:next foo\ bar
    843 
    844 On Unix and a few other systems you can also use backticks, for example: >
    845 	:next `find . -name \\*.c -print`
    846 The backslashes before the star are required to prevent "*.c" to be expanded
    847 by the shell before executing the find program.
    848 
    849 							*arglist-position*
    850 When there is an argument list you can see which file you are editing in the
    851 title of the window (if there is one and 'title' is on) and with the file
    852 message you get with the "CTRL-G" command.  You will see something like
    853 	(file 4 of 11)
    854 If 'shortmess' contains 'f' it will be
    855 	(4 of 11)
    856 If you are not really editing the file at the current position in the argument
    857 list it will be
    858 	(file (4) of 11)
    859 This means that you are position 4 in the argument list, but not editing the
    860 fourth file in the argument list.  This happens when you do ":e file".
    861 
    862 
    863 LOCAL ARGUMENT LIST
    864 
    865 							*:arglocal*
    866 :argl[ocal]		Make a local copy of the global argument list.
    867 			Doesn't start editing another file.
    868 
    869 :argl[ocal][!] [++opt] [+cmd] {arglist}
    870 			Define a new argument list, which is local to the
    871 			current window.  Works like |:args_f| otherwise.
    872 
    873 							*:argglobal*
    874 :argg[lobal]		Use the global argument list for the current window.
    875 			Doesn't start editing another file.
    876 
    877 :argg[lobal][!] [++opt] [+cmd] {arglist}
    878 			Use the global argument list for the current window.
    879 			Define a new global argument list like |:args_f|.
    880 			All windows using the global argument list will see
    881 			this new list.
    882 
    883 There can be several argument lists.  They can be shared between windows.
    884 When they are shared, changing the argument list in one window will also
    885 change it in the other window.
    886 
    887 When a window is split the new window inherits the argument list from the
    888 current window.  The two windows then share this list, until one of them uses
    889 |:arglocal| or |:argglobal| to use another argument list.
    890 
    891 
    892 USING THE ARGUMENT LIST
    893 
    894 						*:argdo*
    895 :[range]argdo[!] {cmd}	Execute {cmd} for each file in the argument list or
    896 			if [range] is specified only for arguments in that
    897 			range.  It works like doing this: >
    898 				:rewind
    899 				:{cmd}
    900 				:next
    901 				:{cmd}
    902 				etc.
    903 <			When the current file can't be |abandon|ed and the [!]
    904 			is not present, the command fails.
    905 			When an error is detected on one file, further files
    906 			in the argument list will not be visited.
    907 			The last file in the argument list (or where an error
    908 			occurred) becomes the current file.
    909 			{cmd} can contain '|' to concatenate several commands.
    910 			{cmd} must not change the argument list.
    911 			Note: While this command is executing, the Syntax
    912 			autocommand event is disabled by adding it to
    913 			'eventignore'.  This considerably speeds up editing
    914 			each file.
    915 			Also see |:windo|, |:tabdo|, |:bufdo|, |:cdo|, |:ldo|,
    916 			|:cfdo| and |:lfdo|
    917 
    918 Example: >
    919 	:args *.c
    920 	:argdo set ff=unix | update
    921 This sets the 'fileformat' option to "unix" and writes the file if it is now
    922 changed.  This is done for all *.c files.
    923 
    924 Example: >
    925 	:args *.[ch]
    926 	:argdo %s/\<my_foo\>/My_Foo/ge | update
    927 This changes the word "my_foo" to "My_Foo" in all *.c and *.h files.  The "e"
    928 flag is used for the ":substitute" command to avoid an error for files where
    929 "my_foo" isn't used.  ":update" writes the file only if changes were made.
    930 
    931 ==============================================================================
    932 4. Writing					*writing* *save-file*
    933 
    934 Note: When the 'write' option is off, you are not able to write any file.
    935 
    936 							*:w* *:write*
    937 					*E502* *E503* *E504* *E505*
    938 					*E512* *E514* *E667* *E949*
    939 :w[rite] [++opt]	Write the whole buffer to the current file.  This is
    940 			the normal way to save changes to a file.  It fails
    941 			when the 'readonly' option is set or when there is
    942 			another reason why the file can't be written.
    943 			For ++opt see |++opt|, but only ++bin, ++nobin, ++ff
    944 			and ++enc are effective.
    945 
    946 :w[rite]! [++opt]	Like ":write", but forcefully write when 'readonly' is
    947 			set or there is another reason why writing was
    948 			refused.
    949 			Note: This may change the permission and ownership of
    950 			the file and break (symbolic) links.  Add the 'W' flag
    951 			to 'cpoptions' to avoid this.
    952 
    953 :[range]w[rite][!] [++opt]
    954 			Write the specified lines to the current file.  This
    955 			is unusual, because the file will not contain all
    956 			lines in the buffer.
    957 
    958 							*:w_f* *:write_f*
    959 :[range]w[rite] [++opt]	{file}
    960 			Write the specified lines to {file}, unless it
    961 			already exists and the 'writeany' option is off.
    962 
    963 							*:w!*
    964 :[range]w[rite]! [++opt] {file}
    965 			Write the specified lines to {file}.  Overwrite an
    966 			existing file.
    967 
    968 						*:w_a* *:write_a* *E494*
    969 :[range]w[rite][!] [++opt] >>
    970 			Append the specified lines to the current file.
    971 
    972 :[range]w[rite][!] [++opt] >> {file}
    973 			Append the specified lines to {file}.  '!' forces the
    974 			write even if file does not exist.
    975 
    976 							*:w_c* *:write_c*
    977 :[range]w[rite] [++opt] !{cmd}
    978 			Execute {cmd} with [range] lines as standard input
    979 			(note the space in front of the '!').  {cmd} is
    980 			executed like with ":!{cmd}", any '!' is replaced with
    981 			the previous command |:!|.
    982 
    983 The default [range] for the ":w" command is the whole buffer (1,$).  The |'[|
    984 and |']| marks will be set to the [range] being used for the write command.
    985 If you write the whole buffer, it is no longer considered changed.  When you
    986 write it to a different file with ":w somefile" it depends on the "+" flag in
    987 'cpoptions'.  When included, the write command will reset the 'modified' flag,
    988 even though the buffer itself may still be different from its file.
    989 
    990 If a file name is given with ":w" it becomes the alternate file.  This can be
    991 used, for example, when the write fails and you want to try again later with
    992 ":w #".  This can be switched off by removing the 'A' flag from the
    993 'cpoptions' option.
    994 
    995 Note that the 'fsync' option matters here.  If it's set it may make writes
    996 slower (but safer).
    997 
    998 							*:sav* *:saveas*
    999 :sav[eas][!] [++opt] {file}
   1000 			Save the current buffer under the name {file} and set
   1001 			the filename of the current buffer to {file}.  The
   1002 			previous name is used for the alternate file name.
   1003 			The [!] is needed to overwrite an existing file.
   1004 			When 'filetype' is empty filetype detection is done
   1005 			with the new name, before the file is written.
   1006 			When the write was successful 'readonly' is reset.
   1007 
   1008 							*:up* *:update*
   1009 :[range]up[date][!] [++opt] [>>] [file]
   1010 			Like ":write", but only write when the buffer has been
   1011 			modified.
   1012 
   1013 
   1014 WRITING WITH MULTIPLE BUFFERS				*buffer-write*
   1015 
   1016 							*:wa* *:wall*
   1017 :wa[ll]			Write all changed buffers.  Buffers without a file
   1018 			name cause an error message.  Buffers which are
   1019 			readonly are not written.
   1020 
   1021 :wa[ll]!		Write all changed buffers, even the ones that are
   1022 			readonly.  Buffers without a file name are not
   1023 			written and cause an error message.
   1024 
   1025 
   1026 Vim will warn you if you try to overwrite a file that has been changed
   1027 elsewhere.  See |timestamp|.
   1028 
   1029 			    *backup* *E207* *E506* *E507* *E508* *E509* *E510*
   1030 If you write to an existing file (but do not append) while the 'backup',
   1031 'writebackup' or 'patchmode' option is on, a backup of the original file is
   1032 made.  The file is either copied or renamed (see 'backupcopy').  After the
   1033 file has been successfully written and when the 'writebackup' option is on and
   1034 the 'backup' option is off, the backup file is deleted.  When the 'patchmode'
   1035 option is on the backup file may be renamed.
   1036 
   1037 							*backup-table*
   1038 'backup' 'writebackup'	action	~
   1039    off	     off	no backup made
   1040    off	     on		backup current file, deleted afterwards (default)
   1041    on	     off	delete old backup, backup current file
   1042    on	     on		delete old backup, backup current file
   1043 
   1044 When the 'backupskip' pattern matches with the name of the file which is
   1045 written, no backup file is made.  The values of 'backup' and 'writebackup' are
   1046 ignored then.
   1047 
   1048 When the 'backup' option is on, an old backup file (with the same name as the
   1049 new backup file) will be deleted.  If 'backup' is not set, but 'writebackup'
   1050 is set, an existing backup file will not be deleted.  The backup file that is
   1051 made while the file is being written will have a different name.
   1052 
   1053 On some filesystems it's possible that in a crash you lose both the backup and
   1054 the newly written file (it might be there but contain bogus data).  In that
   1055 case try recovery, because the swap file is synced to disk and might still be
   1056 there. |:recover|
   1057 
   1058 The directories given with the 'backupdir' option are used to put the backup
   1059 file in.  (default: same directory as the written file).
   1060 
   1061 Whether the backup is a new file, which is a copy of the original file, or the
   1062 original file renamed depends on the 'backupcopy' option.  See there for an
   1063 explanation of when the copy is made and when the file is renamed.
   1064 
   1065 If the creation of a backup file fails, the write is not done.  If you want
   1066 to write anyway add a '!' to the command.
   1067 
   1068 							*file-watcher*
   1069 When you notice issues with programs, that act upon when a buffer is written
   1070 (like inotify, entr or fswatch) or when external applications execute Vim to
   1071 edit the file (like git) and those programs do not seem to notice that the
   1072 original file has been changed, you may want to consider switching the
   1073 'backupcopy' option value to "yes".  This makes sure, Vim writes to the same
   1074 file, that those watcher programs expect, without creating a new file (which
   1075 prevents them from detecting that the file has changed).  See also |crontab|
   1076 
   1077 							*write-permissions*
   1078 When writing a new file the permissions are read-write.  For unix the mask is
   1079 0o666 with additionally umask applied.  When writing a file that was read Vim
   1080 will preserve the permissions, but clear the s-bit.
   1081 
   1082 							*write-readonly*
   1083 When the 'cpoptions' option contains 'W', Vim will refuse to overwrite a
   1084 readonly file.  When 'W' is not present, ":w!" will overwrite a readonly file,
   1085 if the system allows it (the directory must be writable).
   1086 
   1087 							*write-fail*
   1088 If the writing of the new file fails, you have to be careful not to lose
   1089 your changes AND the original file.  If there is no backup file and writing
   1090 the new file failed, you have already lost the original file!  DON'T EXIT VIM
   1091 UNTIL YOU WRITE OUT THE FILE!  If a backup was made, it is put back in place
   1092 of the original file (if possible).  If you exit Vim, and lose the changes
   1093 you made, the original file will mostly still be there.  If putting back the
   1094 original file fails, there will be an error message telling you that you
   1095 lost the original file.
   1096 
   1097 						*DOS-format-write*
   1098 If the 'fileformat' is "dos", <CR><NL> is used for <EOL>.  This is default
   1099 for Win32.  On other systems the message "[dos format]" is shown to remind you
   1100 that an unusual <EOL> was used.
   1101 						*Unix-format-write*
   1102 If the 'fileformat' is "unix", <NL> is used for <EOL>.  On Win32 the message
   1103 "[unix format]" is shown.
   1104 						*Mac-format-write*
   1105 If the 'fileformat' is "mac", <CR> is used for <EOL>.  On non-Mac systems the
   1106 message "[mac format]" is shown.
   1107 
   1108 See also |file-formats| and the 'fileformat' and 'fileformats' options.
   1109 
   1110 						*ACL*
   1111 ACL stands for Access Control List.  It is an advanced way to control access
   1112 rights for a file.  It is used on new MS-Windows and Unix systems, but only
   1113 when the filesystem supports it.
   1114    Vim attempts to preserve the ACL info when writing a file.  The backup file
   1115 will get the ACL info of the original file.
   1116    The ACL info is also used to check if a file is read-only (when opening the
   1117 file).
   1118 
   1119 					*xattr* *E1506* *E1508* *E1509*
   1120 xattr stands for Extended Attributes.  It is an advanced way to save metadata
   1121 alongside the file in the filesystem.  It depends on the actual filesystem
   1122 being used and Vim supports it only on a Linux system.
   1123    Vim attempts to preserve the extended attribute info when writing a file.
   1124 The backup file will get the extended attribute of the original file.
   1125 
   1126 						*read-only-share*
   1127 When MS-Windows shares a drive on the network it can be marked as read-only.
   1128 This means that even if the file read-only attribute is absent, and the ACL
   1129 settings on NT network shared drives allow writing to the file, you can still
   1130 not write to the file.  Vim on Win32 platforms will detect read-only network
   1131 drives and will mark the file as read-only.  You will not be able to override
   1132 it with |:write|.
   1133 
   1134 						*write-device*
   1135 When the file name is actually a device name, Vim will not make a backup (that
   1136 would be impossible).  You need to use "!", since the device already exists.
   1137 Example for Unix: >
   1138 	:w! /dev/lpt0
   1139 and for MS-Windows: >
   1140 	:w! lpt0
   1141 For Unix a device is detected when the name doesn't refer to a normal file or
   1142 a directory.  A fifo or named pipe also looks like a device to Vim.
   1143 For MS-Windows the device is detected by its name:
   1144 	AUX
   1145 	CON
   1146 	CLOCK$
   1147 	NUL
   1148 	PRN
   1149 	COMn	n=1,2,3... etc
   1150 	LPTn	n=1,2,3... etc
   1151 The names can be in upper- or lowercase.
   1152 
   1153 ==============================================================================
   1154 5. Writing and quitting					*write-quit*
   1155 
   1156 							*:q* *:quit*
   1157 :q[uit]			Quit the current window.  Quit Vim if this is the last
   1158 			|edit-window|.  This fails when changes have been made
   1159 			and Vim refuses to |abandon| the current buffer, and
   1160 			when the last file in the argument list has not been
   1161 			edited.
   1162 			If there are other tab pages and quitting the last
   1163 			window in the current tab page the current tab page is
   1164 			closed |tab-page|.
   1165 			Triggers the |QuitPre| autocommand event.
   1166 			See |CTRL-W_q| for quitting another window.
   1167 
   1168 :conf[irm] q[uit]	Quit, but give prompt when changes have been made, or
   1169 			the last file in the argument list has not been
   1170 			edited.  See |:confirm| and 'confirm'.
   1171 
   1172 :q[uit]!		Quit without writing, also when the current buffer has
   1173 			changes.  The buffer is unloaded, also when it has
   1174 			'hidden' set.
   1175 			If this is the last window and there is a modified
   1176 			hidden buffer, the current buffer is abandoned and the
   1177 			first changed hidden buffer becomes the current
   1178 			buffer.
   1179 			Use ":qall!" to exit always.
   1180 
   1181 :cq[uit]		Quit always, without writing, and return an error
   1182 			code.  See |:cq|.  Used for Manx's QuickFix mode (see
   1183 			|quickfix|).
   1184 
   1185 							*:wq*
   1186 :wq [++opt]		Write the current file and close the window.  If this
   1187 			was the last |edit-window| Vim quits.
   1188 			Writing fails when the file is read-only or the buffer
   1189 			does not have a name.  Quitting fails when the last
   1190 			file in the argument list has not been edited.
   1191 
   1192 :wq! [++opt]		Write the current file and close the window.  If this
   1193 			was the last |edit-window| Vim quits.  Writing fails
   1194 			when the current buffer does not have a name.
   1195 
   1196 :wq [++opt] {file}	Write to {file} and close the window.  If this was the
   1197 			last |edit-window| Vim quits.  Quitting fails when the
   1198 			last file in the argument list has not been edited.
   1199 
   1200 :wq! [++opt] {file}	Write to {file} and close the current window.  Quit
   1201 			Vim if this was the last |edit-window|.
   1202 
   1203 :[range]wq[!] [++opt] [file]
   1204 			Same as above, but only write the lines in [range].
   1205 
   1206 							*:x* *:xit*
   1207 :[range]x[it][!] [++opt] [file]
   1208 			Like ":wq", but write only when changes have been
   1209 			made.
   1210 			When 'hidden' is set and there are more windows, the
   1211 			current buffer becomes hidden, after writing the file.
   1212 			This command is not supported in |Vim9| script,
   1213 			because it is too easily confused with a variable
   1214 			name.
   1215 
   1216 							*:exi* *:exit*
   1217 :[range]exi[t][!] [++opt] [file]
   1218 			Same as :xit.
   1219 
   1220 							*ZZ*
   1221 ZZ			Write current file, if modified, and close the current
   1222 			window (same as ":x").
   1223 			If there are several windows for the current file,
   1224 			only the current window is closed.
   1225 
   1226 							*ZQ*
   1227 ZQ			Quit without checking for changes (same as ":q!").
   1228 
   1229 
   1230 MULTIPLE WINDOWS AND BUFFERS				*window-exit*
   1231 
   1232 							*:qa* *:qall*
   1233 :qa[ll]		Exit Vim, unless there are some buffers which have been
   1234 		changed.  (Use ":bmod" to go to the next modified buffer).
   1235 		When 'autowriteall' is set all changed buffers will be
   1236 		written, like |:wqall|.
   1237 
   1238 :conf[irm] qa[ll]
   1239 		Exit Vim.  Bring up a prompt when some buffers have been
   1240 		changed.  See |:confirm|.
   1241 
   1242 :qa[ll]!	Exit Vim.  Any changes to buffers are lost.
   1243 		Also see |:cquit|, it does the same but exits with a non-zero
   1244 		value.
   1245 
   1246 							*:quita* *:quitall*
   1247 :quita[ll][!]	Same as ":qall".
   1248 
   1249 :wqa[ll] [++opt]				*:wqa* *:wqall* *:xa* *:xall*
   1250 :xa[ll]		Write all changed buffers and exit Vim.  If there are buffers
   1251 		without a file name, which are readonly or which cannot be
   1252 		written for another reason, Vim will not quit.
   1253 
   1254 :conf[irm] wqa[ll] [++opt]
   1255 :conf[irm] xa[ll]
   1256 		Write all changed buffers and exit Vim.  Bring up a prompt
   1257 		when some buffers are readonly or cannot be written for
   1258 		another reason.  See |:confirm|.
   1259 
   1260 :wqa[ll]! [++opt]
   1261 :xa[ll]!	Write all changed buffers, even the ones that are readonly,
   1262 		and exit Vim.  If there are buffers without a file name or
   1263 		which cannot be written for another reason, or there is a
   1264 		terminal with a running job, Vim will not quit.
   1265 
   1266 ==============================================================================
   1267 6. Dialogs						*edit-dialogs*
   1268 
   1269 							*:confirm* *:conf*
   1270 :conf[irm] {command}	Execute {command}, and use a dialog when an
   1271 			operation has to be confirmed.  Can be used on the
   1272 			|:q|, |:qa| and |:w| commands (the latter to override
   1273 			a read-only setting), and any other command that can
   1274 			fail in such a way, such as |:only|, |:buffer|,
   1275 			|:bdelete|, etc.
   1276 
   1277 Examples: >
   1278   :confirm w foo
   1279 <	Will ask for confirmation when "foo" already exists. >
   1280   :confirm q
   1281 <	Will ask for confirmation when there are changes. >
   1282   :confirm qa
   1283 <	If any modified, unsaved buffers exist, you will be prompted to save
   1284 	or abandon each one.  There are also choices to "save all" or "abandon
   1285 	all".
   1286 
   1287 If you want to always use ":confirm", set the 'confirm' option.
   1288 
   1289 							*:browse* *:bro* *E338*
   1290 :bro[wse] {command}	Open a file selection dialog for an argument to
   1291 			{command}.  At present this works for |:e|, |:w|,
   1292 			|:wall|, |:wq|, |:wqall|, |:x|, |:xall|, |:exit|,
   1293 			|:view|, |:sview|, |:r|, |:saveas|, |:sp|, |:mkexrc|,
   1294 			|:mkvimrc|, |:mksession|, |:mkview|, |:split|,
   1295 			|:vsplit|, |:tabe|, |:tabnew|, |:cfile|, |:cgetfile|,
   1296 			|:caddfile|, |:lfile|, |:lgetfile|, |:laddfile|,
   1297 			|:diffsplit|, |:diffpatch|, |:open|, |:pedit|,
   1298 			|:redir|, |:source|, |:update|, |:visual|, |:vsplit|,
   1299 			and |:qall| if 'confirm' is set.
   1300 			{only in Win32, Motif, GTK and Mac GUI, in
   1301 			console `browse edit` works if the FileExplorer
   1302 			autocommand group exists}
   1303 			When ":browse" is not possible you get an error
   1304 			message.  If the |+browse| feature is missing or the
   1305 			{command} doesn't support browsing, the {command} is
   1306 			executed without a dialog.
   1307 			":browse set" works like |:options|.
   1308 			See also |:oldfiles| for ":browse oldfiles".
   1309 
   1310 The syntax is best shown via some examples: >
   1311 	:browse e $vim/foo
   1312 <		Open the browser in the $vim/foo directory, and edit the
   1313 		file chosen. >
   1314 	:browse e
   1315 <		Open the browser in the directory specified with 'browsedir',
   1316 		and edit the file chosen. >
   1317 	:browse w
   1318 <		Open the browser in the directory of the current buffer,
   1319 		with the current buffer filename as default, and save the
   1320 		buffer under the filename chosen. >
   1321 	:browse w C:/bar
   1322 <		Open the browser in the C:/bar directory, with the current
   1323 		buffer filename as default, and save the buffer under the
   1324 		filename chosen.
   1325 Also see the 'browsedir' option.
   1326 For versions of Vim where browsing is not supported, the command is executed
   1327 unmodified.
   1328 
   1329 							*browsefilter*
   1330 For MS-Windows and GTK, you can modify the filters that are used in the browse
   1331 dialog.  By setting the g:browsefilter or b:browsefilter variables, you can
   1332 change the filters globally or locally to the buffer.  The variable is set to
   1333 a string in the format "{filter label}\t{pattern};{pattern}\n" where {filter
   1334 label} is the text that appears in the "Files of Type" comboBox, and {pattern}
   1335 is the pattern which filters the filenames.  Several patterns can be given,
   1336 separated by ';'.
   1337 
   1338 For Motif the same format is used, but only the very first pattern is actually
   1339 used (Motif only offers one pattern, but you can edit it).
   1340 
   1341 For example, to have only Vim files in the dialog, you could use the following
   1342 command: >
   1343 
   1344      let g:browsefilter = "Vim scripts\t*.vim\nVim Startup Files\t*vimrc\n"
   1345 
   1346 You can override the filter setting on a per-buffer basis by setting the
   1347 b:browsefilter variable.  You would most likely set b:browsefilter in a
   1348 filetype plugin, so that the browse dialog would contain entries related to
   1349 the type of file you are currently editing.  Disadvantage: This makes it
   1350 difficult to start editing a file of a different type.  To overcome this, you
   1351 can add the following as the final filter on Windows: >
   1352 
   1353 	All Files\t(*.*)\t*\n
   1354 <
   1355 Or the following on other platforms, so that the user can still access any
   1356 desired file: >
   1357 
   1358 	All Files\t(*)\t*\n
   1359 <
   1360 
   1361 To avoid setting browsefilter when Vim does not actually support it, you can
   1362 use has("browsefilter"): >
   1363 
   1364 	if has("browsefilter")
   1365 	   let g:browsefilter = "whatever"
   1366 	endif
   1367 
   1368 ==============================================================================
   1369 7. The current directory				*current-directory*
   1370 
   1371 You can use the |:cd|, |:tcd| and |:lcd| commands to change to another
   1372 directory, so you will not have to type that directory name in front of the
   1373 file names.  It also makes a difference for executing external commands, e.g.
   1374 ":!ls".
   1375 
   1376 Changing directory fails when the current buffer is modified, the '.' flag is
   1377 present in 'cpoptions' and "!" is not used in the command.
   1378 
   1379 							*:cd* *E747* *E472*
   1380 :cd[!]			On non-Unix systems when 'cdhome' is off: Print the
   1381 			current directory name.
   1382 			Otherwise: Change the current directory to the home
   1383 			directory.  Clear any window-local directory.
   1384 			Use |:pwd| to print the current directory on all
   1385 			systems.
   1386 
   1387 :cd[!] {path}		Change the current directory to {path}.
   1388 			If {path} is relative, it is searched for in the
   1389 			directories listed in 'cdpath'.
   1390 			Clear any window-local directory.
   1391 			Does not change the meaning of an already opened file,
   1392 			because its full path name is remembered.  Files from
   1393 			the |arglist| may change though!
   1394 			On MS-Windows this also changes the active drive.
   1395 			To change to the directory of the current file: >
   1396 				:cd %:h
   1397 <
   1398 							*:cd-* *E186*
   1399 :cd[!] -		Change to the previous current directory (before the
   1400 			previous ":cd {path}" command).
   1401 
   1402 							*:chd* *:chdir*
   1403 :chd[ir][!] [path]	Same as |:cd|.
   1404 
   1405 							*:tc* *:tcd*
   1406 :tc[d][!] {path}	Like |:cd|, but only set the directory for the current
   1407 			tab.  The current window will also use this directory.
   1408 			The current directory is not changed for windows in
   1409 			other tabs and for windows in the current tab that
   1410 			have their own window-local directory.
   1411 
   1412 							*:tcd-*
   1413 :tc[d][!] -		Change to the previous current directory, before the
   1414 			last ":tcd {path}" command.
   1415 
   1416 							*:tch* *:tchdir*
   1417 :tch[dir][!]		Same as |:tcd|.
   1418 
   1419 							*:lc* *:lcd*
   1420 :lc[d][!] {path}	Like |:cd|, but only set the current directory when
   1421 			the cursor is in the current window.  The current
   1422 			directory for other windows is not changed, switching
   1423 			to another window will stop using {path}.
   1424 
   1425 							*:lcd-*
   1426 :lc[d][!] -		Change to the previous current directory, before the
   1427 			last ":lcd {path}" command.
   1428 
   1429 							*:lch* *:lchdir*
   1430 :lch[dir][!]		Same as |:lcd|.
   1431 
   1432 							*:pw* *:pwd* *E187*
   1433 :pw[d]			Print the current directory name.
   1434 			Also see |getcwd()|.
   1435 							*:pwd-verbose*
   1436 			When 'verbose' is non-zero, |:pwd| will also display
   1437 			what scope the current directory was set.  Example: >
   1438 
   1439 				" Set by :cd
   1440 				:verbose pwd
   1441 				[global] /path/to/current
   1442 
   1443 				" Set by :lcd
   1444 				:verbose pwd
   1445 				[window] /path/to/current
   1446 
   1447 				" Set by :tcd
   1448 				:verbose pwd
   1449 				[tabpage] /path/to/current
   1450 
   1451 So long as no |:lcd| or |:tcd| command has been used, all windows share the
   1452 same current directory.  Using a command to jump to another window doesn't
   1453 change anything for the current directory.
   1454 
   1455 When a |:lcd| command has been used for a window, the specified directory
   1456 becomes the current directory for that window.  Windows where the |:lcd|
   1457 command has not been used stick to the global or tab-local current directory.
   1458 When jumping to another window the current directory is changed to the last
   1459 specified local current directory.  If none was specified, the global or
   1460 tab-local current directory is used.  When creating a new window it inherits
   1461 the local directory of the current window.
   1462 
   1463 When a |:tcd| command has been used for a tab page, the specified directory
   1464 becomes the current directory for the current tab page and the current window.
   1465 The current directory of other tab pages is not affected.  When jumping to
   1466 another tab page, the current directory is changed to the last specified local
   1467 directory for that tab page.  If the current tab has no local current
   1468 directory the global current directory is used.
   1469 
   1470 When a |:cd| command is used, the current window and tab page will lose the
   1471 local current directory and will use the global current directory from now on.
   1472 
   1473 After using |:cd| the full path name will be used for reading and writing
   1474 files.  On some networked file systems this may cause problems.  The result of
   1475 using the full path name is that the file names currently in use will remain
   1476 referring to the same file.  Example: If you have a file a:test and a
   1477 directory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the file
   1478 a:test and not write a:vim/test.  But if you do ":w test" the file a:vim/test
   1479 will be written, because you gave a new file name and did not refer to a
   1480 filename before the ":cd".
   1481 
   1482 ==============================================================================
   1483 8. Editing binary files					*edit-binary*
   1484 
   1485 Although Vim was made to edit text files, it is possible to edit binary
   1486 files.  The |-b| Vim argument (b for binary) makes Vim do file I/O in binary
   1487 mode, and sets some options for editing binary files ('binary' on, 'textwidth'
   1488 to 0, 'modeline' off, 'expandtab' off).  Setting the 'binary' option has the
   1489 same effect.  Don't forget to do this before reading the file.
   1490 
   1491 There are a few things to remember when editing binary files:
   1492 - When editing executable files the number of bytes must not change.
   1493   Use only the "R" or "r" command to change text.  Do not delete characters
   1494   with "x" or by backspacing.
   1495 - Set the 'textwidth' option to 0.  Otherwise lines will unexpectedly be
   1496   split in two.
   1497 - When there are not many <EOL>s, the lines will become very long.  If you
   1498   want to edit a line that does not fit on the screen reset the 'wrap' option.
   1499   Horizontal scrolling is used then.  If a line becomes too long (more than
   1500   about 32767 bytes on the Amiga, much more on 32-bit and 64-bit systems, see
   1501   |limits|) you cannot edit that line.  The line will be split when reading
   1502   the file.  It is also possible that you get an "out of memory" error when
   1503   reading the file.
   1504 - Make sure the 'binary' option is set BEFORE loading the
   1505   file.  Otherwise both <CR><NL> and <NL> are considered to end a line
   1506   and when the file is written the <NL> will be replaced with <CR><NL>.
   1507 - <Nul> characters are shown on the screen as ^@.  You can enter them with
   1508   "CTRL-V CTRL-@" or "CTRL-V 000"
   1509 - To insert a <NL> character in the file split a line.  When writing the
   1510   buffer to a file a <NL> will be written for the <EOL>.
   1511 - Vim normally appends an <EOL> at the end of the file if there is none.
   1512   Setting the 'binary' option prevents this.  If you want to add the final
   1513   <EOL>, set the 'endofline' option.  You can also read the value of this
   1514   option to see if there was an <EOL> for the last line (you cannot see this
   1515   in the text).
   1516 
   1517 ==============================================================================
   1518 9. Encryption						*encryption*
   1519 
   1520 Vim is able to write files encrypted, and read them back.  The encrypted text
   1521 cannot be read without the right key.
   1522 {only available when compiled with the |+cryptv| feature}  *E833*
   1523 
   1524 The text in the swap file and the undo file is also encrypted.  *E843*
   1525 However, this is done block-by-block and may reduce the time needed to crack a
   1526 password.  You can disable the swap file, but then a crash will cause you to
   1527 lose your work.  The undo file can be disabled without too much disadvantage. >
   1528 	:set noundofile
   1529 	:noswapfile edit secrets
   1530 
   1531 Note: The text in memory is not encrypted.  A system administrator may be able
   1532 to see your text while you are editing it.  When filtering text with
   1533 ":!filter" or using ":w !command" the text is also not encrypted, this may
   1534 reveal it to others.  The 'viminfo' file is not encrypted.
   1535 
   1536 You could do this to edit very secret text: >
   1537 	:set noundofile viminfo=
   1538 	:noswapfile edit secrets.txt
   1539 Keep in mind that without a swap file you risk losing your work in the event
   1540 of a crash or a power failure.
   1541 
   1542 WARNING: If you make a typo when entering the key and then write the file and
   1543 exit, the text will be lost!
   1544 
   1545 The normal way to work with encryption, is to use the ":X" command, which will
   1546 ask you to enter a key.  A following write command will use that key to
   1547 encrypt the file.  If you later edit the same file, Vim will ask you to enter
   1548 a key.  If you type the same key as that was used for writing, the text will
   1549 be readable again.  If you use a wrong key, it will be a mess.
   1550 
   1551 							*:X*
   1552 :X	Prompt for an encryption key.  The typing is done without showing the
   1553 	actual text, so that someone looking at the display won't see it.
   1554 	The typed key is stored in the 'key' option, which is used to encrypt
   1555 	the file when it is written.
   1556 	The file will remain unchanged until you write it.  Note that commands
   1557 	such as `:xit` and `ZZ` will NOT write the file unless there are other
   1558 	changes.
   1559 	See also |-x|.
   1560 
   1561 The value of the 'key' options is used when text is written.  When the option
   1562 is not empty, the written file will be encrypted, using the value as the
   1563 encryption key.  A magic number is prepended, so that Vim can recognize that
   1564 the file is encrypted.
   1565 
   1566 To disable the encryption, reset the 'key' option to an empty value: >
   1567 	:set key=
   1568 
   1569 You can use the 'cryptmethod' option to select the type of encryption, use one
   1570 of these: >
   1571 	:setlocal cm=zip          " weak method, backwards compatible
   1572 	:setlocal cm=blowfish     " method with flaws, do not use
   1573 	:setlocal cm=blowfish2    " medium strong method
   1574 	:setlocal cm=xchacha20v2  " medium strong method using libsodium
   1575 
   1576 Do this before writing the file.  When reading an encrypted file it will be
   1577 set automatically to the method used when that file was written.  You can
   1578 change 'cryptmethod' before writing that file to change the method.
   1579 
   1580 To set the default method, used for new files, use this in your |vimrc|
   1581 file: >
   1582 	set cm=blowfish2
   1583 Using "blowfish2" is highly recommended.  Only use another method if you
   1584 must use an older Vim version that does not support it.
   1585 
   1586 The message given for reading and writing a file will show "[crypted]" when
   1587 using zip, "[blowfish]" when using blowfish, etc.
   1588 
   1589 When writing an undo file, the same key and method will be used for the text
   1590 in the undo file. |persistent-undo|.
   1591 
   1592 To test for blowfish support you can use these conditions: >
   1593 	has('crypt-blowfish')
   1594 	has('crypt-blowfish2')
   1595 This works since Vim 7.4.1099 while blowfish support was added earlier.
   1596 Thus the condition failing doesn't mean blowfish is not supported.  You can
   1597 test for blowfish with: >
   1598 	v:version >= 703
   1599 And for blowfish2 with: >
   1600 	v:version > 704 || (v:version == 704 && has('patch401'))
   1601 If you are sure Vim includes patch 7.4.237 a simpler check is: >
   1602 	has('patch-7.4.401')
   1603 <
   1604 						*E817* *E818* *E819* *E820*
   1605 When encryption does not work properly, you would be able to write your text
   1606 to a file and never be able to read it back.  Therefore a test is performed to
   1607 check if the encryption works as expected.  If you get one of these errors
   1608 don't write the file encrypted!  You need to rebuild the Vim binary to fix
   1609 this.
   1610 
   1611 *E831* This is an internal error, "cannot happen".  If you can reproduce it,
   1612 please report to the developers.
   1613 
   1614 When reading a file that has been encrypted and the 'key' option is not empty,
   1615 it will be used for decryption.  If the value is empty, you will be prompted
   1616 to enter the key.  If you don't enter a key, or you enter the wrong key, the
   1617 file is edited without being decrypted.  There is no warning about using the
   1618 wrong key (this makes brute force methods to find the key more difficult).
   1619 
   1620 If want to start reading a file that uses a different key, set the 'key'
   1621 option to an empty string, so that Vim will prompt for a new one.  Don't use
   1622 the ":set" command to enter the value, other people can read the command over
   1623 your shoulder.
   1624 
   1625 Since the value of the 'key' option is supposed to be a secret, its value can
   1626 never be viewed.  You should not set this option in a vimrc file.
   1627 
   1628 An encrypted file can be recognized by the "file" command, if you add these
   1629 lines to "/etc/magic", "/usr/share/misc/magic" or wherever your system has the
   1630 "magic" file: >
   1631      0	string	VimCrypt~	Vim encrypted file
   1632      >9	string	01	- "zip" cryptmethod
   1633      >9	string	02	- "blowfish" cryptmethod
   1634      >9	string	03	- "blowfish2" cryptmethod
   1635 
   1636 Notes:
   1637 - Encryption is not possible when doing conversion with 'charconvert'.
   1638 - Text you copy or delete goes to the numbered registers.  The registers can
   1639   be saved in the .viminfo file, where they could be read.  Change your
   1640   'viminfo' option to be safe.
   1641 - Someone can type commands in Vim when you walk away for a moment, he should
   1642   not be able to get the key.
   1643 - If you make a typing mistake when entering the key, you might not be able to
   1644   get your text back!
   1645 - If you type the key with a ":set key=value" command, it can be kept in the
   1646   history, showing the 'key' value in a viminfo file.
   1647 - There is never 100% safety.  The encryption in Vim has not been tested for
   1648   robustness.
   1649 - The algorithm used for 'cryptmethod' "zip" is breakable.  A 4 character key
   1650   in about one hour, a 6 character key in one day (on a Pentium 133 PC).  This
   1651   requires that you know some text that must appear in the file.  An expert
   1652   can break it for any key.  When the text has been decrypted, this also means
   1653   that the key can be revealed, and other files encrypted with the same key
   1654   can be decrypted.
   1655 - Pkzip uses the same encryption as 'cryptmethod' "zip", and US Govt has no
   1656   objection to its export.  Pkzip's public file APPNOTE.TXT describes this
   1657   algorithm in detail.
   1658 - The implementation of 'cryptmethod' "blowfish" has a flaw.  It is possible
   1659   to crack the first 64 bytes of a file and in some circumstances more of the
   1660   file.  Use of it is not recommended, but it's still the strongest method
   1661   supported by Vim 7.3 and 7.4.  The "zip" method is even weaker.
   1662 - Vim originates from the Netherlands.  That is where the sources come from.
   1663   Thus the encryption code is not exported from the USA.
   1664 
   1665 ==============================================================================
   1666 10. Timestamps					*timestamp* *timestamps*
   1667 
   1668 Vim remembers the modification timestamp, mode and size of a file when you
   1669 begin editing it.  This is used to avoid that you have two different versions
   1670 of the same file (without you knowing this).
   1671 
   1672 After a shell command is run (|:!cmd| |suspend| |:read!| |K|) timestamps,
   1673 file modes and file sizes are compared for all buffers in a window.   Vim will
   1674 run any associated |FileChangedShell| autocommands or display a warning for
   1675 any files that have changed.  In the GUI this happens when Vim regains input
   1676 focus.
   1677 
   1678 							*E321* *E462*
   1679 If you want to automatically reload a file when it has been changed outside of
   1680 Vim, set the 'autoread' option.  This doesn't work at the moment you write the
   1681 file though, only when the file wasn't changed inside of Vim.
   1682 							*ignore-timestamp*
   1683 If you do not want to be asked or automatically reload the file, you can use
   1684 this: >
   1685 	set buftype=nofile
   1686 
   1687 Or, when starting gvim from a shell: >
   1688 	gvim file.log -c "set buftype=nofile"
   1689 
   1690 Note that if a FileChangedShell autocommand is defined you will not get a
   1691 warning message or prompt.  The autocommand is expected to handle this.
   1692 
   1693 There is no warning for a directory (e.g., with |netrw-browse|).  But you do
   1694 get warned if you started editing a new file and it was created as a directory
   1695 later.
   1696 
   1697 When Vim notices the timestamp of a file has changed, and the file is being
   1698 edited in a buffer but has not changed, Vim checks if the contents of the file
   1699 is equal.  This is done by reading the file again (into a hidden buffer, which
   1700 is immediately deleted again) and comparing the text.  If the text is equal,
   1701 you will get no warning.
   1702 
   1703 If you don't get warned often enough you can use the following command.
   1704 
   1705 							*:checkt* *:checktime*
   1706 :checkt[ime]		Check if any buffers were changed outside of Vim.
   1707 			This checks and warns you if you would end up with two
   1708 			versions of a file.
   1709 			If this is called from an autocommand, a ":global"
   1710 			command or is not typed the actual check is postponed
   1711 			until a moment the side effects (reloading the file)
   1712 			would be harmless.
   1713 			Each loaded buffer is checked for its associated file
   1714 			being changed.  If the file was changed Vim will take
   1715 			action.  If there are no changes in the buffer and
   1716 			'autoread' is set, the buffer is reloaded.  Otherwise,
   1717 			you are offered the choice of reloading the file.  If
   1718 			the file was deleted you get an error message.
   1719 			If the file previously didn't exist you get a warning
   1720 			if it exists now.
   1721 			Once a file has been checked the timestamp is reset,
   1722 			you will not be warned again.
   1723 			Syntax highlighting, marks, diff status,
   1724 			'fileencoding', 'fileformat' and 'binary' options
   1725 			are not changed.  See |v:fcs_choice| to reload these
   1726 			too (for example, if a code formatting tools has
   1727 			changed the file).
   1728 
   1729 :[N]checkt[ime] {filename}
   1730 :[N]checkt[ime] [N]
   1731 			Check the timestamp of a specific buffer.  The buffer
   1732 			may be specified by name, number or with a pattern.
   1733 
   1734 
   1735 							*E813* *E814*
   1736 Vim will reload the buffer if you chose to.  If a window is visible that
   1737 contains this buffer, the reloading will happen in the context of this window.
   1738 Otherwise a special window is used, so that most autocommands will work.  You
   1739 can't close this window.  A few other restrictions apply.  Best is to make
   1740 sure nothing happens outside of the current buffer.  E.g., setting
   1741 window-local options may end up in the wrong window.  Splitting the window,
   1742 doing something there and closing it should be OK (if there are no side
   1743 effects from other autocommands).  Closing unrelated windows and buffers will
   1744 get you into trouble.
   1745 
   1746 Before writing a file the timestamp is checked.  If it has changed, Vim will
   1747 ask if you really want to overwrite the file:
   1748 
   1749 	WARNING: The file has been changed since reading it!!!
   1750 	Do you really want to write to it (y/n)?
   1751 
   1752 If you hit 'y' Vim will continue writing the file.  If you hit 'n' the write
   1753 is aborted.  If you used ":wq" or "ZZ" Vim will not exit, you will get another
   1754 chance to write the file.
   1755 
   1756 The message would normally mean that somebody has written to the file after
   1757 the edit session started.  This could be another person, in which case you
   1758 probably want to check if your changes to the file and the changes from the
   1759 other person should be merged.  Write the file under another name and check
   1760 for differences (the "diff" program can be used for this).
   1761 
   1762 It is also possible that you modified the file yourself, from another edit
   1763 session or with another command (e.g., a filter command).  Then you will know
   1764 which version of the file you want to keep.
   1765 
   1766 The accuracy of the time check depends on the filesystem.  On Unix it is
   1767 usually sub-second.  With old file systems and on MS-Windows it is normally
   1768 one second.  Use `has('nanotime')` to check if sub-second time stamp checks
   1769 are available.
   1770 
   1771 There is one situation where you get the message while there is nothing wrong:
   1772 On a Win32 system on the day daylight saving time starts.  There is something
   1773 in the Win32 libraries that confuses Vim about the hour time difference.  The
   1774 problem goes away the next day.
   1775 
   1776 ==============================================================================
   1777 11. File Searching					*file-searching*
   1778 
   1779 The file searching is currently used for the 'path', 'cdpath' and 'tags'
   1780 options, for |finddir()| and |findfile()|.  Other commands use |wildcards|
   1781 which is slightly different.
   1782 
   1783 There are three different types of searching:
   1784 
   1785 1) Downward search:					*starstar*
   1786    Downward search uses the wildcards '*', '**' and possibly others
   1787    supported by your operating system.  '*' and '**' are handled inside Vim,
   1788    so they work on all operating systems.  Note that "**" only acts as a
   1789    special wildcard when it is at the start of a name.
   1790 
   1791    The usage of '*' is quite simple: It matches 0 or more characters.  In a
   1792    search pattern this would be ".*".  Note that the "." is not used for file
   1793    searching.
   1794 
   1795    '**' is more sophisticated:
   1796       - It ONLY matches directories.
   1797       - It matches up to 30 directories deep by default, so you can use it to
   1798 	search an entire directory tree
   1799       - The maximum number of levels matched can be given by appending a
   1800 	number to '**'.
   1801 	Thus '/usr/**2' can match: >
   1802 		/usr
   1803 		/usr/include
   1804 		/usr/include/sys
   1805 		/usr/include/g++
   1806 		/usr/lib
   1807 		/usr/lib/X11
   1808 		....
   1809 <	It does NOT match '/usr/include/g++/std' as this would be three
   1810 	levels.
   1811 	The allowed number range is 0 ('**0' is removed) to 100
   1812 	If the given number is smaller than 0 it defaults to 30, if it's
   1813 	bigger than 100 then 100 is used.  The system also has a limit on the
   1814 	path length, usually 256 or 1024 bytes.
   1815       - '**' can only be at the end of the path or be followed by a path
   1816 	separator or by a number and a path separator.
   1817 
   1818    You can combine '*' and '**' in any order: >
   1819 	/usr/**/sys/*
   1820 	/usr/*tory/sys/**
   1821 	/usr/**2/sys/*
   1822 
   1823 2) Upward search:
   1824    Here you can give a directory and then search the directory tree upward for
   1825    a file.  You could give stop-directories to limit the upward search.  The
   1826    stop-directories are appended to the path (for the 'path' option) or to
   1827    the filename (for the 'tags' option) with a ';'.  If you want several
   1828    stop-directories separate them with ';'.  If you want no stop-directory
   1829    ("search upward till the root directory") just use ';'. >
   1830 	/usr/include/sys;/usr
   1831 <   will search in: >
   1832 	   /usr/include/sys
   1833 	   /usr/include
   1834 	   /usr
   1835 <
   1836    If you use a relative path the upward search is started in Vim's current
   1837    directory or in the directory of the current file (if the relative path
   1838    starts with './' and 'd' is not included in 'cpoptions').
   1839 
   1840    If Vim's current path is /u/user_x/work/release and you do >
   1841 	:set path=include;/u/user_x
   1842 <   and then search for a file with |gf| the file is searched in: >
   1843 	/u/user_x/work/release/include
   1844 	/u/user_x/work/include
   1845 	/u/user_x/include
   1846 
   1847 <   Note: If your 'path' setting includes a non-existing directory, Vim will
   1848    skip the non-existing directory, and also does not search in the parent of
   1849    the non-existing directory if upwards searching is used.
   1850 
   1851 3) Combined up/downward search:
   1852    If Vim's current path is /u/user_x/work/release and you do >
   1853 	set path=**;/u/user_x
   1854 <   and then search for a file with |gf| the file is searched in: >
   1855 	/u/user_x/work/release/**
   1856 	/u/user_x/work/**
   1857 	/u/user_x/**
   1858 <
   1859    BE CAREFUL!  This might consume a lot of time, as the search of
   1860    '/u/user_x/**' includes '/u/user_x/work/**' and
   1861    '/u/user_x/work/release/**'.  So '/u/user_x/work/release/**' is searched
   1862    three times and '/u/user_x/work/**' is searched twice.
   1863 
   1864    In the above example you might want to set path to: >
   1865 	:set path=**,/u/user_x/**
   1866 <   This searches: >
   1867 	/u/user_x/work/release/**
   1868 	/u/user_x/**
   1869 <   This searches the same directories, but in a different order.
   1870 
   1871    Note that completion for ":find", ":sfind", and ":tabfind" commands do not
   1872    currently work with 'path' items that contain a URL or use the double star
   1873    with depth limiter (/usr/**2) or upward search (;) notations.
   1874 
   1875  vim:tw=78:ts=8:noet:ft=help:norl: