Editing
Nvim:help pages,generated fromsource using thetree-sitter-vimdoc parser.
Editing files
Editing a file with Vim means:
1. reading the file into a buffer2. changing the buffer with editor commands3. writing the buffer into a file
current-fileAs long as you don't write the buffer, the original file remains unchanged.If you start editing a file (read a file into the buffer), the file name isremembered as the "current file name". This is also known as the name of thecurrent buffer. It can be used with "%" on the command line
:_%.
alternate-fileIf there already was a current file name, then that one becomes the alternatefile name. It can be used with "#" on the command line
:_# and you can usethe
CTRL-^ command to toggle between the current and the alternate file.However, the alternate file name is not changed when
:keepalt is used.An alternate file name is remembered for each window.
:keepa:keepalt:keepa[lt]
{cmd}Execute
{cmd} while keeping the current alternate filename. Note that commands invoked indirectly (e.g.,with a function) may still set the alternate filename.
All file names are remembered in the buffer list. When you enter a file name,for editing (e.g., with ":e filename") or writing (e.g., with ":w filename"),the file name is added to the list. You can use the buffer list to rememberwhich files you edited and to quickly switch from one file to another (e.g.,to copy text) with the
CTRL-^ command. First type the number of the fileand then hit
CTRL-^.
CTRL-Gor
CTRL-G:f:fi:file:f[ile]Prints the current file name (as typed, unless ":cd"was used), the cursor position (unless the
'ruler'option is set), and the file status (readonly,modified, read errors, new file). See the
'shortmess'option about how to make this message shorter.
:f[ile]!like
:file, but don't truncate the name even when
'shortmess' indicates this.
{count}CTRL-GLikeCTRL-G, but prints the current file name withfull path. If the count is higher than 1 the currentbuffer number is also given.
g_CTRL-Gword-countbyte-countg
CTRL-GPrints the current position of the cursor in fiveways: Column, Line, Word, Character and Byte. If thenumber of Characters and Bytes is the same then theCharacter position is omitted.
If there are characters in the line that take morethan one position on the screen (
<Tab> or specialcharacter), or characters using more than one byte percolumn (characters above 0x7F when
'encoding' isutf-8), both the byte column and the screen column areshown, separated by a dash.
v_g_CTRL-G{Visual}g
CTRL-GSimilar to "g
CTRL-G", but Word, Character, Line, andByte counts for the visually selected region aredisplayed.In Blockwise mode, Column count is also shown. (For
{Visual} see
Visual-mode.)
:file_f:f[ile][!]
{name}Sets the current file name to
{name}. The optional !avoids truncating the message, as with
:file.If the buffer did have a name, that name becomes the
alternate-file name. An unlisted buffer is createdto hold the old name.
:0file:0f[ile][!]Remove the name of the current buffer. The optional !avoids truncating the message, as with
:file.
Vim will remember the full path name of a file name that you enter. In mostcases when the file name is displayed only the name you typed is shown, butthe full path name is being used if you used the ":cd" command
:cd.
home-replaceIf the environment variable $HOME is set, and the file name starts with thatstring, it is often displayed with HOME replaced with "~". This was done tokeep file names short. When reading or writing files the full name is stillused, the "~" is only used when displaying file names. When replacing thefile name would result in just "~", "~/" is used instead (to avoid confusionbetween options set to $HOME with
'backupext' set to "~").
When writing the buffer, the default is to use the current file name. Thuswhen you give the "ZZ" or ":wq" command, the original file will beoverwritten. If you do not want this, the buffer can be written into anotherfile by giving a file name argument to the ":write" command. For example:
vim testfile[change the buffer with editor commands]:w newfile:q
This will create a file "newfile", that is a modified copy of "testfile".The file "testfile" will remain unchanged. Anyway, if the
'backup' option isset, Vim renames or copies the original file before it will be overwritten.You can use this file if you discover that you need the original file. Seealso the
'patchmode' option. The name of the backup file is normally the sameas the original file with
'backupext' appended. The default "~" is a bitstrange to avoid accidentally overwriting existing files. If you prefer".bak" change the
'backupext' option. The backup file can be placed inanother directory by setting
'backupdir'.
When you started editing without giving a file name, "No File" is displayed inmessages. If the ":write" command is used with a file name argument, the filename for the current file is set to that file name. This only happens whenthe 'F' flag is included in
'cpoptions' (by default it is included)
cpo-F.This is useful when entering text in an empty buffer and then writing it to afile. If
'cpoptions' contains the 'f' flag (by default it is NOT included)
cpo-f the file name is set for the ":read file" command. This is usefulwhen starting Vim without an argument and then doing ":read file" to startediting a file.When the file name was set and
'filetype' is empty the filetype detectionautocommands will be triggered.
not-editedBecause the file name was set without really starting to edit that file, youare protected from overwriting that file. This is done by setting the"notedited" flag. You can see if this flag is set with the
CTRL-G or ":file"command. It will include "[Not edited]" when the "notedited" flag is set.When writing the buffer to the current file name (with ":w!"), the "notedited"flag is reset.
abandonVim remembers whether you have changed the buffer. You are protected fromlosing the changes you made. If you try to quit without writing, or want tostart editing another file, Vim will refuse this. In order to overrule thisprotection, add a '!' to the command. The changes will then be lost. Forexample: ":q" will not work if the buffer was changed, but ":q!" will. To seewhether the buffer was changed use the "CTRL-G" command. The message includesthe string "[Modified]" if the buffer has been changed, or "+" if the 'm' flagis in
'shortmess'.
If you want to automatically save the changes without asking, switch on the
'autowriteall' option.
'autowrite' is the associated Vi-compatible optionthat does not work for all commands.
If you want to keep the changed buffer without saving it, switch on the
'hidden' option. See
hidden-buffer. Some commands work like this even when
'hidden' is not set, check the help for the command.
:e:editreload:e[dit][!] [++opt] [+cmd]Edit the current file. This is useful to re-edit thecurrent file, when it has been changed outside of Vim.
:edit!discardIf [!] is given, unsaved changes in the current bufferare discarded. Without [!] the command fails if thereare unsaved changes, unless
'autowriteall' is set andthe file can be written.Also see
++opt and
+cmd.
:edit_f:e[dit][!] [++opt] [+cmd]
{file}Edit
{file}.
:edit!_fIf [!] is given, unsaved changes in the current bufferare discarded. Without [!] the command fails if thereare unsaved changes, unless
'hidden' is set or
'autowriteall' is set and the file can be written.Also see
++opt and
+cmd.
:edit_#:e#:e[dit] [++opt] [+cmd] #[count]Edit the [count]th buffer (as shown by
:files).This command does the same as [count]
CTRL-^. But ":e#" doesn't work if the alternate buffer doesn't have afile name, while
CTRL-^ still works then.Also see
++opt and
+cmd.
:{count}fin[d][!] [++opt] [+cmd]
{file}Just like ":find", but use the
{count} match in
'path'. Thus ":2find file" will find the second"file" found in
'path'. When there are fewer matchesfor the file in
'path' than asked for, you get anerror message.
:ex:ex [++opt] [+cmd] [file]Same as
:edit.
:vi:visual:vi[sual][!] [++opt] [+cmd] [file]When used in Ex mode: Leave
Ex-mode, go back toNormal mode. Otherwise same as
:edit.
:vie:view:vie[w][!] [++opt] [+cmd] fileWhen used in Ex mode: Leave
Ex-mode, go back toNormal mode. Otherwise same as
:edit, but set
'readonly' option for this buffer.
CTRL-^CTRL-6CTRL-^Edit the alternate file. Mostly the alternate file isthe previously edited file. This is a quick way totoggle between two files. It is equivalent to ":e #",except that it also works when there is no file name.
If the
'autowrite' or
'autowriteall' option is on andthe buffer was changed, write it.Mostly the ^ character is positioned on the 6 key,pressing CTRL and 6 then gets you what we call
CTRL-^.But on some non-US keyboards
CTRL-^ is produced inanother way.
{count}CTRL-^Edit [count]th file in the buffer list (equivalent to":e #[count]"). This is a quick way to switch betweenfiles.See
CTRL-^ above for further details.
gfE446E447[count]gfEdit the file whose name is under or after the cursor.Mnemonic: "goto file".Uses the
'isfname' option to find out which charactersare supposed to be in a file name. Trailingpunctuation characters ".,:;!" are ignored. Escapedspaces "\ " are reduced to a single space.Uses the
'path' option as a list of directory names tolook for the file. See the
'path' option for detailsabout relative directories and wildcards.Uses the
'suffixesadd' option to check for file nameswith a suffix added.If the file can't be found,
'includeexpr' is used tomodify the name and another attempt is done.If a [count] is given, the count'th file that is foundin the
'path' is edited.This command fails if Vim refuses to
abandon thecurrent file.If you want to edit the file in a new window use
CTRL-W_CTRL-F.If you do want to edit a new file, use:
:e <cfile>
To make gf always work like that:
:map gf :e <cfile><CR>
If the name is a hypertext link, that looks like"type://machine/path", you need the |netrw| plugin.For Unix the '~' character is expanded, like in"~user/file". Environment variables are expanded too
expand-env.
v_gf{Visual}[count]gfSame as "gf", but the highlighted text is used as thename of the file to edit.
'isfname' is ignored.Leading blanks are skipped, otherwise all blanks andspecial characters are included in the file name.(For
{Visual} see
Visual-mode.)
gF[count]gFSame as "gf", except if a number follows the filename, then the cursor is positioned on that line inthe file.The file name and the number must be separated by anon-filename (see
'isfname') and non-numericcharacter. " line " is also recognized, like it isused in the output of
:verbose command UserCmdWhite space between the filename, the separator andthe number are ignored.Examples:
eval.c:10
eval.c @ 20
eval.c (30)
eval.c 40
v_gF{Visual}[count]gFSame as "v_gf".
These commands are used to start editing a single file. This means that thefile is read into the buffer and the current file name is set. The file thatis opened depends on the current directory, see
:cd.
See
read-messages for an explanation of the message that is given after thefile has been read.
You can use the ":e!" command if you messed up the buffer and want to startall over again. The ":e" command is only useful if you have changed thecurrent file name.
Note for systems other than Unix: When using a command that accepts a singlefile name (like ":edit file") spaces in the file name are allowed, buttrailing spaces are ignored. This is useful on systems that regularly embedspaces in file names (like MS-Windows). Example: The command ":e Long FileName " will edit the file "Long File Name". When using a command that acceptsmore than one file name (like ":next file1 file2") embedded spaces must beescaped with a backslash.
wildcardwildcardsWildcards in
{file} are expanded, but as with file completion,
'wildignore'and
'suffixes' apply. Which wildcards are supported depends on the system.These are the common ones:
? matches one character
* matches anything, including nothing
** matches anything, including nothing, recurses into directories[abc]match 'a', 'b' or 'c'
To avoid the special meaning of the wildcards prepend a backslash. However,on MS-Windows the backslash is a path separator and "path\[abc]" is still seenas a wildcard when "[" is in the
'isfname' option. A simple way to avoid thisis to use "path\[[]abc]", this matches the file "path\[abc]".
starstar-wildcardExpanding "**" is possible on Unix, Win32, macOS and a few other systems (butit may depend on your
'shell' setting on Unix and macOS. It's known to workcorrectly for zsh; for bash this requires at least bash version >= 4.X).This allows searching a directory tree. This goes up to 100 directories deep.Note there are some commands where this works slightly differently, see
file-searching.Example:
:n **/*.txt
Finds files:
aaa.txt
subdir/bbb.txt
a/b/c/d/ccc.txt
When non-wildcard characters are used right before or after "**" these areonly matched in the top directory. They are not used for directories furtherdown in the tree. For example:
:n /usr/inc**/types.h
Finds files:
/usr/include/types.h
/usr/include/sys/types.h
/usr/inc/old/types.h
Note that the path with "/sys" is included because it does not need to match"/inc". Thus it's like matching "/usr/inc*/*/*...", not"/usr/inc*/inc*/inc*".
backtick-expansion`-expansionOn Unix and a few other systems you can also use backticks for the file nameargument, for example:
:next `find . -name ver\\*.c -print`:view `ls -t *.patch \| head -n1`
Vim will run the command in backticks using the
'shell' and use the standardoutput as argument for the given Vim command (error messages from the shellcommand will be discarded).To see what shell command Vim is running, set the
'verbose' option to 4. Whenthe shell command returns a non-zero exit code, an error message will bedisplayed and the Vim command will be aborted. To avoid this make the shellalways return zero like so:
:next `find . -name ver\\*.c -print \|\| true`
The backslashes before the star are required to prevent the shell fromexpanding "ver*.c" prior to execution of the find program. The backslashbefore the shell pipe symbol "|" prevents Vim from parsing it as commandtermination.This also works for most other systems, with the restriction that thebackticks must be around the whole item. It is not possible to have textdirectly before the first or just after the last backtick.
`=You can have the backticks expanded as a Vim expression, instead of as anexternal command, by putting an equal sign right after the first backtick,e.g.:
:e `=tempname()`
The expression can contain just about anything, thus this can also be used toavoid the special meaning of '"', "|", '%' and '#'. However,
'wildignore'does apply like to other wildcards.
Environment variables in the expression are expanded when evaluating theexpression, thus this works:
:e `=$HOME .. '/.vimrc'`
This uses $HOME inside a string and it will be used literally, most likely notwhat you intended:
:e `='$HOME' .. '/.vimrc'`
If the expression returns a string then names are to be separated with linebreaks. When the result is a
List then each item is used as a name. Linebreaks also separate names.Note that such expressions are only supported in places where a filename isexpected as an argument to an Ex-command.
++opt[++opt]The [++opt] argument can be used to set some options for one command, and tospecify the behavior for bad characters. The form is:
++{optname}Or:
++{optname}={value}Where
{optname} is one of:
++ff++enc++bin++nobin++edit ff or fileformat overrides
'fileformat' enc or encoding overrides
'fileencoding' bin or binary sets
'binary' nobin or nobinary resets
'binary' bad specifies behavior for bad characters edit for
:read: keeps options as if editing a file p for
:write: creates the file's parent directory
{value} cannot contain whitespace. It can be any valid value for the options.Examples:
:e ++ff=unix
This edits the same file again with
'fileformat' set to "unix".
:w ++enc=latin1 newfile
This writes the current buffer to "newfile" in latin1 format.
The message given when writing a file will show "[converted]" when
'fileencoding' or the value specified with ++enc differs from
'encoding'.
There may be several ++opt arguments, separated by whitespace. They must allappear before any
+cmd argument.
++pThe "++p" flag creates the parent directory of the file if it does not exist.For example if you edit "foo/bar/file.txt", the ":write ++p" command creates"foo/bar/" if necessary before writing the file.
:edit foo/bar/file.txt:write ++p
If you want :write (without "++p") to always create missing parentdirectories, add this autocmd to your config:
" Auto-create parent directories (except for URIs "://").au BufWritePre,FileWritePre * if @% !~# '\(://\)' | call mkdir(expand('<afile>:p:h'), 'p') | endif ++badThe argument of "++bad=" specifies what happens with characters that can't beconverted and illegal bytes. It can be one of three things: ++bad=X A single-byte character that replaces each bad character. ++bad=keep Keep bad characters without conversion. Note that this may result in illegal bytes in your text! ++bad=drop Remove the bad characters.
The default is like "++bad=?": Replace each bad character with a questionmark. In some places an inverted question mark is used (0xBF).
Note that not all commands use the ++bad argument, even though they do notgive an error when you add it. E.g.
:write.
Note that when reading, the
'fileformat' and
'fileencoding' options will beset to the used format. When writing this doesn't happen, thus a next writewill use the old value of the option. Same for the
'binary' option.
+cmd[+cmd]The [+cmd] argument can be used to position the cursor in the newly openedfile, or execute any other command:+Start at the last line.+{num}Start at line
{num}.+/{pat}Start at first line containing
{pat}.+{command}Execute
{command} after opening the new file.
{command} is any Ex command.To include a white space in the
{pat} or
{command}, precede it with abackslash. Double the number of backslashes.
:edit +/The\ book file:edit +/dir\ dirname\\ file:edit +set\ dir=c:\\\\temp file
Note that in the last example the number of backslashes is halved twice: Oncefor the "+cmd" argument and once for the ":set" command.
When reading a file, the mentioned characters are interpreted as the
<EOL>.In DOS format (default for Windows),
<CR><NL> and
<NL> are both interpreted asthe
<EOL>. Note that when writing the file in DOS format,
<CR> characters willbe added for each single
<NL>. Also see
file-read.
When writing a file, the mentioned characters are used for
<EOL>. For DOSformat
<CR><NL> is used. Also see
DOS-format-write.
You can read a file in DOS format and write it in Unix format. This willreplace all
<CR><NL> pairs by
<NL> (assuming
'fileformats' includes "dos"):
:e file:set fileformat=unix:w
If you read a file in Unix format and write with DOS format, all
<NL>characters will be replaced with
<CR><NL> (assuming
'fileformats' includes"unix"):
:e file:set fileformat=dos:w
If you start editing a new file and the
'fileformats' option is not empty(which is the default), Vim will try to detect whether the lines in the fileare separated by the specified formats. When set to "unix,dos", Vim willcheck for lines with a single
<NL> (as used on Unix) or by a
<CR><NL> pair(MS-Windows). Only when ALL lines end in
<CR><NL>,
'fileformat' isset to "dos", otherwise it is set to "unix". When
'fileformats' includes"mac", and no
<NL> characters are found in the file,
'fileformat' is set to"mac".
If the
'fileformat' option is set to "dos" on non-MS-Windows systems themessage "[dos]" is shown to remind you that something unusual is happening. OnMS-Windows systems you get the message "[unix]" if
'fileformat' is set to"unix". On all systems you get the message "[mac]" if
'fileformat' is set to"mac".
If the
'fileformats' option is empty and DOS format is used, but while readinga file some lines did not end in
<CR><NL>, "[CR missing]" will be included inthe file message.If the
'fileformats' option is empty and Mac format is used, but while readinga file a
<NL> was found, "[NL missing]" will be included in the file message.
Before editing binary, executable or Vim script files you should set the
'binary' option. A simple way to do this is by starting Vim with the "-b"option. This will avoid the use of
'fileformat'. Without this you risk thatsingle
<NL> characters are unexpectedly replaced with
<CR><NL>.
The first three values are normally detected automatically when reading thefile and are used when writing the text to a file. While editing the bufferit looks like every line has a line ending and the
CTRL-Z isn't there (anexception is when
'binary' is set, it works differently then).
The
'fixendofline' option can be used to choose what to write. You can alsochange the option values to write the file differently than how it was read.
Here are some examples how to use them.
If you want files in Unix format (every line NL terminated):
setl ff=unix fixeol
You should probably do this on any Unix-like system. Also modern MS-Windowssystems tend to work well with this. It is recommended to always use thisformat for Vim scripts.
If you want to use an old MS-DOS file in a modern environment, fixing lineendings and dropping
CTRL-Z, but keeping the
<CR><NL> style
<EOL>:
setl ff=dos fixeol
This is useful for many MS-Windows programs, they regularly expect the
<CR><NL> line endings.
If you want to drop the final
<EOL> and add a final
CTRL-Z (e.g. for an oldsystem like CP/M):
setl ff=dos nofixeol noeol eof
If you want to preserve the fileformat exactly as-is, including any final
<EOL> and final
CTRL-Z:
setl nofixeol
If you give more than one file name when starting Vim, this list is rememberedas the argument list. You can jump to each file in this list.
Do not confuse this with the buffer list, which you can see with the
:buffers command. The argument list was already present in Vi, the bufferlist is new in Vim. Every file name in the argument list will also be presentin the buffer list (unless it was deleted with
:bdel or
:bwipe). But it'scommon that names in the buffer list are not in the argument list.
This subject is introduced in section
07.2 of the user manual.
There is one global argument list, which is used for all windows by default.It is possible to create a new argument list local to a window, see
:arglocal.
You can use the argument list with the following commands, and with theexpression functions
argc() and
argv(). These all work on the argumentlist of the current window.
:ar:arg:args:ar[gs]Print the argument list, with the current file insquare brackets.
:ar[gs] [++opt] [+cmd]
{arglist}:args_fDefine
{arglist} as the new argument list and editthe first one. This fails when changes have been madeand Vim does not want to
abandon the current buffer.Also see
++opt and
+cmd.
:ar[gs]! [++opt] [+cmd]
{arglist}:args_f!Define
{arglist} as the new argument list and editthe first one. Discard any changes to the currentbuffer.Also see
++opt and
+cmd.
:[count]arge[dit][!] [++opt] [+cmd]
{name} ...
:arge:argeditAdd
{name}s to the argument list and edit it.There is no check for duplicates, it is possible toadd a file to the argument list twice
:argded.This is like using
:argadd and then
:edit (withthe small exception that
:edit does not change theargument list, so the argument list pointer isn'tchanged).Spaces in filenames have to be escaped with "\".[count] is used like with
:argadd.If the current file cannot be
abandoned
{name}s willstill be added to the argument list, but won't beedited. No check for duplicates is done.Also see
++opt and
+cmd.
:[count]arga[dd]
{name} ...
:arga:argaddE479:[count]arga[dd]
E1156Add the
{name}s to the argument list. When
{name} isomitted add the current buffer name to the argumentlist.If [count] is omitted, the
{name}s are added justafter the current entry in the argument list.Otherwise they are added after the [count]'th file.If the argument list is "a b c", and "b" is thecurrent argument, then these commands result in:
commandnew argument list
:argadd xa [b] x c:0argadd xx a [b] c:1argadd xa x [b] c:$argadd xa [b] c xAnd after the last one::+2argadd ya [b] c x yThere is no check for duplicates, it is possible toadd a file to the argument list twice. You can use
:argdedupe to fix it afterwards:
:argadd *.txt | argdedupe
The currently edited file is not changed.
Note: you can also use this method:
:args ## x
This will add the "x" item and sort the new list.
:argded[upe]
:argded:argdedupeRemove duplicate filenames from the argument list.If your current file is a duplicate, your current filewill change to the original file index.
:argd[elete]
{pattern} ...
:argd:argdeleteE480E610Delete files from the argument list that match the
{pattern}s.
{pattern} is used like a file pattern,see
file-pattern. "%" can be used to delete thecurrent entry.This command keeps the currently edited file, alsowhen it's deleted from the argument list.Example:
:argdel *.obj
:[range]argd[elete]Delete the [range] files from the argument list.Example:
:10,$argdel
Deletes arguments 10 and further, keeping 1-9.
:$argd
Deletes just the last one.
:argd:.argd
Deletes the current argument.
:%argd
Removes all the files from the arglist.When the last number in the range is too high, up tothe last argument is deleted.
:argu:argument:[count]argu[ment] [count] [++opt] [+cmd]Edit file [count] in the argument list. When [count]is omitted the current entry is used. This failswhen changes have been made and Vim does not want to
abandon the current buffer.Also see
++opt and
+cmd.
:[count]argu[ment]! [count] [++opt] [+cmd]Edit file [count] in the argument list, discard anychanges to the current buffer. When [count] isomitted the current entry is used.Also see
++opt and
+cmd.
:[count]n[ext] [++opt] [+cmd]
:n:ne:nextE165E163Edit [count] next file. This fails when changes havebeen made and Vim does not want to
abandon thecurrent buffer. Also see
++opt and
+cmd.
:[count]n[ext]! [++opt] [+cmd]Edit [count] next file, discard any changes to thebuffer. Also see
++opt and
+cmd.
:n[ext]! [++opt] [+cmd]
{arglist}Same as
:args_f!.
:[count]N[ext] [count] [++opt] [+cmd]
:Next:NE164Edit [count] previous file in argument list. Thisfails when changes have been made and Vim does notwant to
abandon the current buffer.Also see
++opt and
+cmd.
:[count]N[ext]! [count] [++opt] [+cmd]Edit [count] previous file in argument list. Discardany changes to the buffer. Also see
++opt and
+cmd.
:rew:rewind:rew[ind] [++opt] [+cmd]Start editing the first file in the argument list.This fails when changes have been made and Vim doesnot want to
abandon the current buffer.Also see
++opt and
+cmd.
:rew[ind]! [++opt] [+cmd]Start editing the first file in the argument list.Discard any changes to the buffer. Also see
++optand
+cmd.
:fir:first:fir[st][!] [++opt] [+cmd]Other name for ":rewind".
:la:last:la[st] [++opt] [+cmd]Start editing the last file in the argument list.This fails when changes have been made and Vim doesnot want to
abandon the current buffer.Also see
++opt and
+cmd.
:la[st]! [++opt] [+cmd]Start editing the last file in the argument list.Discard any changes to the buffer. Also see
++optand
+cmd.
:wn:wnext:[count]wn[ext] [++opt]Write current file and start editing the [count]next file. Also see
++opt and
+cmd.
:[count]wn[ext] [++opt]
{file}Write current file to
{file} and start editing the[count] next file, unless
{file} already exists andthe
'writeany' option is off. Also see
++opt and
+cmd.
:[count]wn[ext]! [++opt]
{file}Write current file to
{file} and start editing the[count] next file. Also see
++opt and
+cmd.
:[count]wN[ext][!] [++opt] [file]
:wN:wNext:[count]wp[revious][!] [++opt] [file]
:wp:wpreviousSame as :wnext, but go to previous file instead ofnext.
The [count] in the commands above defaults to one. For some commands it ispossible to use two counts. The last one (rightmost one) is used.
If no [+cmd] argument is present, the cursor is positioned at the last knowncursor position for the file. If
'startofline' is set, the cursor will bepositioned at the first non-blank in the line, otherwise the last know columnis used. If there is no last known cursor position the cursor will be in thefirst line (the last line in Ex mode).
{arglist}The wildcards in the argument list are expanded and the file names are sorted.Thus you can use the command
vim *.c to edit all the C files. From withinVim the command
:n *.c does the same.
White space is used to separate file names. Put a backslash before a space ortab to include it in a file name. E.g., to edit the single file "foo bar":
:next foo\ bar
On Unix and a few other systems you can also use backticks, for example:
:next `find . -name \\*.c -print`
The backslashes before the star are required to prevent "*.c" to be expandedby the shell before executing the find program.
arglist-positionWhen there is an argument list you can see which file you are editing in thetitle of the window (if there is one and
'title' is on) and with the filemessage you get with the "CTRL-G" command. You will see something like(4 of 11)If you are not really editing the file at the current position in the argumentlist it will be((4) of 11)This means that you are position 4 in the argument list, but not editing thefourth file in the argument list. This happens when you do ":e file".
LOCAL ARGUMENT LIST
:arglocal:argl[ocal]Make a local copy of the global argument list.Doesn't start editing another file.
:argl[ocal][!] [++opt] [+cmd]
{arglist}Define a new argument list, which is local to thecurrent window. Works like
:args_f otherwise.
:argglobal:argg[lobal]Use the global argument list for the current window.Doesn't start editing another file.
:argg[lobal][!] [++opt] [+cmd]
{arglist}Use the global argument list for the current window.Define a new global argument list like
:args_f.All windows using the global argument list will seethis new list.
There can be several argument lists. They can be shared between windows.When they are shared, changing the argument list in one window will alsochange it in the other window.
When a window is split the new window inherits the argument list from thecurrent window. The two windows then share this list, until one of them uses
:arglocal or
:argglobal to use another argument list.
USING THE ARGUMENT LIST
:argdo:[range]argdo[!]
{cmd}Execute
{cmd} for each file in the argument list or,if [range] is specified, only for arguments in thatrange. It works like doing this:
:rewind:{cmd}:next:{cmd}etc. When the current file can't be
abandoned and the [!]is not present, the command fails.When an error is detected on one file, further filesin the argument list will not be visited.The last file in the argument list (or where an erroroccurred) becomes the current file.
{cmd} can contain '|' to concatenate several commands.
{cmd} must not change the argument list.
Note: While this command is executing, the Syntaxautocommand event is disabled by adding it to
'eventignore'. This considerably speeds up editingeach file.Also see
:windo,
:tabdo,
:bufdo,
:cdo,
:ldo,
:cfdo and
:lfdo.
Example:
:args *.c:argdo set ff=unix | update
This sets the
'fileformat' option to "unix" and writes the file if it is nowchanged. This is done for all
*.c files.
Example:
:args *.[ch]:argdo %s/\<my_foo\>/My_Foo/ge | update
This changes the word "my_foo" to "My_Foo" in all "*.c" and "*.h" files. The "e"flag is used for the ":substitute" command to avoid an error for files where"my_foo" isn't used. ":update" writes the file only if changes were made.
Note: When the
'write' option is off, you are not able to write any file.
:w:writeE502E503E504E505E512E514E667E949:w[rite] [++opt]Write the whole buffer to the current file. This isthe normal way to save changes to a file. Fails when
'readonly' is set or when there is another reason whythe file can't be written, such as when the parentdirectory doesn't exist (use
++p to avoid that).For ++opt see
++opt, but only ++p, ++bin, ++nobin,++ff and ++enc are effective.
:w[rite]! [++opt]Like ":write", but forcefully write when
'readonly' isset or there is another reason why writing wasrefused.
Note: This may change the permission and ownership ofthe file and break (symbolic) links. Add the 'W' flagto
'cpoptions' to avoid this.
:[range]w[rite][!] [++opt]Write the specified lines to the current file. Thisis unusual, because the file will not contain alllines in the buffer.
:w_f:write_f:[range]w[rite] [++opt]
{file}Write the specified lines to
{file}, unless italready exists and the
'writeany' option is off.
:w!:[range]w[rite]! [++opt]
{file}Write the specified lines to
{file}. Overwrite anexisting file.
:w_a:write_aE494:[range]w[rite][!] [++opt] >
Append the specified lines to the current file.
:[range]w[rite][!] [++opt] >>
{file}Append the specified lines to
{file}. '!' forces thewrite even if file does not exist.
:w_c:write_c:[range]w[rite] [++opt] !{cmd}Execute
{cmd} with [range] lines as standard input(note the space in front of the '!').
{cmd} isexecuted like with ":!{cmd}", any '!' is replaced withthe previous command
:!.
The default [range] for the ":w" command is the whole buffer (1,$). The
'[and
'] marks will be set to the [range] being used for the write command.If you write the whole buffer, it is no longer considered changed. When youwrite it to a different file with ":w somefile" it depends on the "+" flag in
'cpoptions'. When included, the write command will reset the
'modified' flag,even though the buffer itself may still be different from its file.
If a file name is given with ":w" it becomes the alternate file. This can beused, for example, when the write fails and you want to try again later with":w #". This can be switched off by removing the 'A' flag from the
'cpoptions' option.
Note that the
'fsync' option matters here. If it's set it may make writesslower (but safer).
:sav:saveas:sav[eas][!] [++opt]
{file}Save the current buffer under the name
{file} and setthe filename of the current buffer to
{file}. Theprevious name is used for the alternate file name.The [!] is needed to overwrite an existing file.When
'filetype' is empty filetype detection is donewith the new name, before the file is written.When the write was successful
'readonly' is reset.
:up:update:[range]up[date][!] [++opt] [>>] [file]Like ":write", but only write when the buffer has beenmodified, or when the buffer represents a new filethat doesn't exist on disk.
:wa:wall:wa[ll][++opt]Write all changed buffers. Buffers without a filename cause an error message. Buffers which arereadonly are not written.For ++opt see
++opt, but only ++p is effective, andapplies to each written file.
:wa[ll]! [++opt]Write all changed buffers, even the ones that arereadonly. Buffers without a file name are notwritten and cause an error message.
Vim will warn you if you try to overwrite a file that has been changedelsewhere (unless "!" was used). See
timestamp.
backup-table off offno backup made off onbackup current file, deleted afterwards (default) on offdelete old backup, backup current file on ondelete old backup, backup current file
When the
'backup' option is on, an old backup file (with the same name as thenew backup file) will be deleted. If
'backup' is not set, but
'writebackup'is set, an existing backup file will not be deleted. The backup file that ismade while the file is being written will have a different name.
On some filesystems it's possible that in a crash you lose both the backup andthe newly written file (it might be there but contain bogus data). In thatcase try recovery, because the swap file is synced to disk and might still bethere.
:recoverThe directories given with the
'backupdir' option are used to put the backupfile in. (default: same directory as the written file).
Whether the backup is a new file, which is a copy of the original file, or theoriginal file renamed depends on the
'backupcopy' option. See there for anexplanation of when the copy is made and when the file is renamed.
If the creation of a backup file fails, the write is not done. If you wantto write anyway add a '!' to the command.
file-watcherWhen you notice issues with programs, that act upon when a buffer is written(like inotify, entr or fswatch) or when external applications execute Vim toedit the file (like git) and those programs do not seem to notice that theoriginal file has been changed, you may want to consider switching the
'backupcopy' option value to "yes". This makes sure, Vim writes to the samefile, that those watcher programs expect, without creating a new file (whichprevents them from detecting that the file has changed). See also
crontab write-permissionsWhen writing a new file the permissions are read-write. For unix the mask is0o666 with additionally umask applied. When writing a file that was read Vimwill preserve the permissions, but clear the s-bit.
write-readonlyWhen the
'cpoptions' option contains 'W', Vim will refuse to overwrite areadonly file. When 'W' is not present, ":w!" will overwrite a readonly file,if the system allows it (the directory must be writable).
write-failIf the writing of the new file fails, you have to be careful not to loseyour changes AND the original file. If there is no backup file and writingthe new file failed, you have already lost the original file! DON'T EXIT VIMUNTIL YOU WRITE OUT THE FILE! If a backup was made, it is put back in placeof the original file (if possible). If you exit Vim, and lose the changesyou made, the original file will mostly still be there. If putting back theoriginal file fails, there will be an error message telling you that youlost the original file.
ACLACL stands for Access Control List. It is an advanced way to control accessrights for a file. It is used on new MS-Windows and Unix systems, but onlywhen the filesystem supports it. Vim attempts to preserve the ACL info when writing a file. The backup filewill get the ACL info of the original file. The ACL info is also used to check if a file is read-only (when opening thefile).
xattrE1506E1508E1509xattr stands for Extended Attributes. It is an advanced way to save metadataalongside the file in the filesystem. It depends on the actual filesystembeing used and Vim supports it only on a Linux system. Vim attempts to preserve the extended attribute info when writing a file.The backup file will get the extended attribute of the original file.
read-only-shareWhen MS-Windows shares a drive on the network it can be marked as read-only.This means that even if the file read-only attribute is absent, and the ACLsettings on NT network shared drives allow writing to the file, you can stillnot write to the file. Vim on Win32 platforms will detect read-only networkdrives and will mark the file as read-only. You will not be able to overrideit with
:write.
write-deviceWhen the file name is actually a device name, Vim will not make a backup (thatwould be impossible). You need to use "!", since the device already exists.Example for Unix:
:w! /dev/lpt0
and MS-Windows:
:w! lpt0
For Unix a device is detected when the name doesn't refer to a normal file ora directory. A fifo or named pipe also looks like a device to Vim.For MS-Windows the device is detected by its name:CONCLOCK$NULPRNCOMnn=1,2,3... etcLPTnn=1,2,3... etcThe names can be in upper- or lowercase.
:q:quit:q[uit]Quit the current window. Quit Vim if this is the last
edit-window. This fails when changes have been madeand Vim refuses to
abandon the current buffer, andwhen the last file in the argument list has not beenedited.If there are other tab pages and quitting the lastwindow in the current tab page the current tab page isclosed
tab-page.Triggers the
QuitPre autocommand event.See
CTRL-W_q for quitting another window.
:conf[irm] q[uit]Quit, but give prompt when changes have been made, orthe last file in the argument list has not beenedited. See
:confirm and
'confirm'.
:q[uit]!Quit without writing, also when the current buffer haschanges. The buffer is unloaded, also when it has
'hidden' set.If this is the last window and there is a modifiedhidden buffer, the current buffer is abandoned and thefirst changed hidden buffer becomes the currentbuffer.Use ":qall!" to exit always.
:cq[uit]Quit always, without writing, and return an errorcode. See
:cq.
:wq:wq [++opt]Write the current file and close the window. If thiswas the last
edit-window Vim quits.Writing fails when the file is read-only or the bufferdoes not have a name. Quitting fails when the lastfile in the argument list has not been edited.
:wq! [++opt]Write the current file and close the window. If thiswas the last
edit-window Vim quits. Writing failswhen the current buffer does not have a name.
:wq [++opt]
{file}Write to
{file} and close the window. If this was thelast
edit-window Vim quits. Quitting fails when thelast file in the argument list has not been edited.
:wq! [++opt]
{file}Write to
{file} and close the current window. QuitVim if this was the last
edit-window.
:[range]wq[!] [++opt] [file]Same as above, but only write the lines in [range].
:x:xit:[range]x[it][!] [++opt] [file]Like ":wq", but write only when changes have beenmade.When
'hidden' is set and there are more windows, thecurrent buffer becomes hidden, after writing the file.
:exi:exit:[range]exi[t][!] [++opt] [file]Same as :xit.
ZZZZWrite current file, if modified, and close the currentwindow (same as ":x").If there are several windows for the current file,only the current window is closed.
ZQZQQuit without checking for changes (same as ":q!").
:qa:qall:qa[ll]Exit Vim, unless there are some buffers which have beenchanged. (Use ":bmod" to go to the next modified buffer).When
'autowriteall' is set all changed buffers will bewritten, like
:wqall.
:conf[irm] qa[ll]Exit Vim. Bring up a prompt when some buffers have beenchanged. See
:confirm.
:qa[ll]!Exit Vim. Any changes to buffers are lost.Also see
:cquit, it does the same but exits with a non-zerovalue.
:wqa[ll] [++opt]
:wqa:wqall:xa:xall:xa[ll]Write all changed buffers and exit Vim. If there are bufferswithout a file name, which are readonly or which cannot bewritten for another reason, Vim will not quit.
:conf[irm] wqa[ll] [++opt]:conf[irm] xa[ll]Write all changed buffers and exit Vim. Bring up a promptwhen some buffers are readonly or cannot be written foranother reason. See
:confirm.
:wqa[ll]! [++opt]:xa[ll]!Write all changed buffers, even the ones that are readonly,and exit Vim. If there are buffers without a file name orwhich cannot be written for another reason, Vim will not quit.
:confirm:conf:conf[irm]
{command}Execute
{command}, and use a dialog when anoperation has to be confirmed. Can be used on the
:edit,
:restart,
:q,
:qa and
:w commands(the latter to override a read-only setting), and anycommands that can fail because of unsaved changes,such as
:only,
:buffer,
:bdelete, etc.
Will ask for confirmation when "foo" already exists.
:confirm q
Will ask for confirmation when there are changes.
:confirm qa
If any modified, unsaved buffers exist, you will be prompted to saveor abandon each one. There are also choices to "save all" or "abandonall".
If you want to always use ":confirm", set the
'confirm' option.
:browse:broE338E614E615E616:bro[wse]
{command}Open a file selection dialog for an argument to
{command}. At present this works for
:e,
:w,
:wall,
:wq,
:wqall,
:x,
:xall,
:exit,
:view,
:sview,
:r,
:saveas,
:sp,
:mkexrc,
:mkvimrc,
:mksession,
:mkview,
:split,
:vsplit,
:tabe,
:tabnew,
:cfile,
:cgetfile,
:caddfile,
:lfile,
:lgetfile,
:laddfile,
:diffsplit,
:diffpatch,
:pedit,
:redir,
:source,
:update,
:visual,
:vsplit,and
:qall if
'confirm' is set.
Note: only in Win32 GUI; in console
:browse editworks if the FileExplorer autocommand group exists.When ":browse" is not possible you get an errormessage. If
{command} doesn't support browsing, the
{command} is executed without a dialog.":browse set" works like
:options.See also
:oldfiles for ":browse oldfiles".
The syntax is best shown via some examples:
:browse e $vim/foo
Open the browser in the $vim/foo directory, and edit thefile chosen.
:browse e
Open the browser in the directory specified with
'browsedir',and edit the file chosen.
:browse w
Open the browser in the directory of the current buffer,with the current buffer filename as default, and save thebuffer under the filename chosen.
:browse w C:/bar
Open the browser in the C:/bar directory, with the currentbuffer filename as default, and save the buffer under thefilename chosen.Also see the
'browsedir' option.For versions of Vim where browsing is not supported, the command is executedunmodified.
browsefilterFor MS-Windows you can modify the filters that are used in the browsedialog. By setting the g:browsefilter or b:browsefilter variables, you canchange the filters globally or locally to the buffer. The variable is set toa string in the format "{filter label}\t{pattern};{pattern}\n" where "{filterlabel}" is the text that appears in the "Files of Type" comboBox, and
{pattern}is the pattern which filters the filenames. Several patterns can be given,separated by ';'.
For example, to have only Vim files in the dialog, you could use the followingcommand:
let g:browsefilter = "Vim scripts\t*.vim\nVim Startup Files\t*vimrc\n"
You can override the filter setting on a per-buffer basis by setting theb:browsefilter variable. You would most likely set b:browsefilter in afiletype plugin, so that the browse dialog would contain entries related tothe type of file you are currently editing. Disadvantage: This makes itdifficult to start editing a file of a different type. To overcome this, youcan add the following as the final filter on Windows:
All Files\t(*.*)\t*\n
Or the following on other platforms, so that the user can still access anydesired file:
All Files\t(*)\t*\n
To avoid setting browsefilter when Vim does not actually support it, you canuse has("browsefilter"):
if has("browsefilter") let g:browsefilter = "whatever"endifYou can use
:cd,
:tcd and
:lcd to change to another directory, so youwill not have to type that directory name in front of the file names. It alsomakes a difference for executing external commands, e.g. ":!ls" or ":te ls".
There are three current-directory "scopes": global, tab and window. Thewindow-local working directory takes precedence over the tab-localworking directory, which in turn takes precedence over the globalworking directory. If a local working directory (tab or window) does notexist, the next-higher scope in the hierarchy applies.
:cdE747E472:cd[!]On non-Unix systems when
'cdhome' is off: Print thecurrent directory name.Otherwise: Change the current directory to the homedirectory. Clear any window-local directory.Use
:pwd to print the current directory on allsystems.
:cd[!]
{path}Change the current directory to
{path}.If
{path} is relative, it is searched for in thedirectories listed in
'cdpath'.Clear any window-local directory.Does not change the meaning of an already opened file,because its full path name is remembered. Files fromthe
arglist may change though!On MS-Windows this also changes the active drive.To change to the directory of the current file:
:cd %:h
:cd-E186:cd[!] -Change to the previous current directory (before theprevious ":cd
{path}" command).
:tc:tcd:tc[d][!]
{path}Like
:cd, but only set the directory for the currenttab. The current window will also use this directory.The current directory is not changed for windows inother tabs and for windows in the current tab thathave their own window-local directory.
:tcd-:tc[d][!] -Change to the previous current directory (before theprevious ":tcd
{path}" command).
:lc:lcd:lc[d][!]
{path}Like
:cd, but only set the current directory for thecurrent window. The current directory for otherwindows or tabs is not changed.
:lcd-:lc[d][!] -Change to the previous current directory (before theprevious ":lcd
{path}" command).
:pw:pwdE187:pw[d]Print the current directory name.Also see
getcwd().
:pwd-verboseWhen
'verbose' is non-zero,
:pwd will also displaywhat scope the current directory was set. Example:
" Set by :cd:verbose pwd[global] /path/to/current" Set by :lcd:verbose pwd[window] /path/to/current" Set by :tcd:verbose pwd[tabpage] /path/to/current
So long as no
:lcd or
:tcd command has been used, all windows share thesame current directory. Using a command to jump to another window doesn'tchange anything for the current directory.
When
:lcd has been used for a window, the specified directory becomes thecurrent directory for that window. Windows where the
:lcd command has notbeen used stick to the global or tab-local directory. When jumping to anotherwindow the current directory is changed to the last specified local currentdirectory. If none was specified, the global or tab-local directory is used.When creating a new window it inherits the local directory of the current window.
When changing tabs the same behaviour applies. If the current tab has nolocal working directory the global working directory is used.
When a
:cd command is used, the current window and tab will lose their localcurrent directories and will use the global current directory from now on.When a
:tcd command is used, only the current window will lose its localworking directory.
After using
:cd the full path name will be used for reading and writingfiles. On some networked file systems this may cause problems. The result ofusing the full path name is that the file names currently in use will remainreferring to the same file. Example: If you have a file a:test and adirectory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the filea:test and not write a:vim/test. But if you do ":w test" the file a:vim/testwill be written, because you gave a new file name and did not refer to afilename before the ":cd".
Although Vim was made to edit text files, it is possible to edit binaryfiles. The
-b Vim argument (b for binary) makes Vim do file I/O in binarymode, and sets some options for editing binary files (
'binary' on,
'textwidth'to 0,
'modeline' off,
'expandtab' off). Setting the
'binary' option has thesame effect. Don't forget to do this before reading the file.
There are a few things to remember when editing binary files:
When editing executable files the number of bytes must not change. Use only the "R" or "r" command to change text. Do not delete characters with "x" or by backspacing.
Set the
'textwidth' option to 0. Otherwise lines will unexpectedly be split in two.
When there are not many
<EOL>s, the lines will become very long. If you want to edit a line that does not fit on the screen reset the
'wrap' option. Horizontal scrolling is used then. If a line becomes too long (see
limits) you cannot edit that line. The line will be split when reading the file. It is also possible that you get an "out of memory" error when reading the file.
Make sure the
'binary' option is set BEFORE loading the file. Otherwise both
<CR><NL> and
<NL> are considered to end a line and when the file is written the
<NL> will be replaced with
<CR><NL>.
<Nul> characters are shown on the screen as ^@. You can enter them with "CTRL-VCTRL-@" or "CTRL-V 000".
To insert a<NL> character in the file split a line. When writing the buffer to a file a<NL> will be written for the<EOL>.
Vim normally appends an
<EOL> at the end of the file if there is none. Setting the
'binary' option prevents this. If you want to add the final
<EOL>, set the
'endofline' option. You can also read the value of this option to see if there was an
<EOL> for the last line (you cannot see this in the text).
Vim remembers the modification timestamp, mode and size of a file when youbegin editing it. This is used to avoid that you have two different versionsof the same file (without you knowing this).
After a shell command is run (
:!cmdsuspend:read!K) timestamps,file modes and file sizes are compared for all buffers in a window. Vim willrun any associated
FileChangedShell autocommands or display a warning forany files that have changed. In the GUI this happens when Vim regains inputfocus.
E321E462If you want to automatically reload a file when it has been changed outside ofVim, set the
'autoread' option. This doesn't work at the moment you write thefile though, only when the file wasn't changed inside of Vim.
ignore-timestampIf you do not want to be asked or automatically reload the file, you can usethis:
set buftype=nofile
Or, when starting gvim from a shell:
gvim file.log -c "set buftype=nofile"
Note that if a FileChangedShell autocommand is defined you will not get awarning message or prompt. The autocommand is expected to handle this.
There is no warning for a directory. But you do get warned if you startedediting a new file and it was created as a directory later.
When Vim notices the timestamp of a file has changed, and the file is beingedited in a buffer but has not changed, Vim checks if the contents of the fileis equal. This is done by reading the file again (into a hidden buffer, whichis immediately deleted again) and comparing the text. If the text is equal,you will get no warning.
If you don't get warned often enough you can use the following command.
:checkt:checktime:checkt[ime]Check if any buffers were changed outside of Vim.This checks and warns you if you would end up with twoversions of a file.If this is called from an autocommand, a ":global"command or is not typed the actual check is postponeduntil a moment the side effects (reloading the file)would be harmless.Each loaded buffer is checked for its associated filebeing changed. If the file was changed Vim will takeaction. If there are no changes in the buffer and
'autoread' is set, the buffer is reloaded. Otherwise,you are offered the choice of reloading the file. Ifthe file was deleted you get an error message.If the file previously didn't exist you get a warningif it exists now.Once a file has been checked the timestamp is reset,you will not be warned again.Syntax highlighting, marks, diff status,
'fileencoding',
'fileformat' and
'binary' optionsare not changed. See
v:fcs_choice to reload thesetoo (for example, if a code formatting tools haschanged the file).
:[N]checkt[ime]{filename}:[N]checkt[ime] [N]Check the timestamp of a specific buffer. The buffermay be specified by name, number or with a pattern.
E813E814Vim will reload the buffer if you chose to. If a window is visible thatcontains this buffer, the reloading will happen in the context of this window.Otherwise a special window is used, so that most autocommands will work. Youcan't close this window. A few other restrictions apply. Best is to makesure nothing happens outside of the current buffer. E.g., settingwindow-local options may end up in the wrong window. Splitting the window,doing something there and closing it should be OK (if there are no sideeffects from other autocommands). Closing unrelated windows and buffers willget you into trouble.
Before writing a file, the timestamp is checked (unless "!" was used).If it has changed, Vim will ask if you really want to overwrite the file:
WARNING: The file has been changed since reading it!!!Do you really want to write to it (y/n)?
If you hit 'y' Vim will continue writing the file. If you hit 'n' the writeis aborted. If you used ":wq" or "ZZ" Vim will not exit, you will get anotherchance to write the file.
The message would normally mean that somebody has written to the file afterthe edit session started. This could be another person, in which case youprobably want to check if your changes to the file and the changes from theother person should be merged. Write the file under another name and checkfor differences (the "diff" program can be used for this).
It is also possible that you modified the file yourself, from another editsession or with another command (e.g., a filter command). Then you will knowwhich version of the file you want to keep.
The accuracy of the time check depends on the filesystem. On Unix it isusually sub-second. With old file systems and on MS-Windows it is normallyone second. Usehas('nanotime') to check if sub-second time stamp checksare available.
There is one situation where you get the message while there is nothing wrong:On a Win32 system on the day daylight saving time starts. There is somethingin the Win32 libraries that confuses Vim about the hour time difference. Theproblem goes away the next day.
There are three different types of searching:
1) Downward search:
starstar Downward search uses the wildcards "*", "**" and possibly others supported by your operating system. "*" and "**" are handled inside Vim, so they work on all operating systems. Note that "**" only acts as a special wildcard when it is at the start of a name.
The usage of "*" is quite simple: It matches 0 or more characters. In a search pattern this would be ".*". Note that the "." is not used for file searching.
"**" is more sophisticated:
It ONLY matches directories.
It matches up to 30 directories deep by default, so you can use it tosearch an entire directory tree
The maximum number of levels matched can be given by appending anumber to "**".Thus '/usr/**2' can match:
/usr/usr/include/usr/include/sys/usr/include/g++/usr/lib/usr/lib/X11....
It does NOT match '/usr/include/g++/std' as this would be threelevels.The allowed number range is 0 ("**0" is removed) to 100If the given number is smaller than 0 it defaults to 30, if it'sbigger than 100 then 100 is used. The system also has a limit on thepath length, usually 256 or 1024 bytes.
"**" can only be at the end of the path or be followed by a pathseparator or by a number and a path separator.
You can combine "*" and "**" in any order:
/usr/**/sys/*/usr/*tory/sys/**/usr/**2/sys/*
2) Upward search: Here you can give a directory and then search the directory tree upward for a file. You could give stop-directories to limit the upward search. The stop-directories are appended to the path (for the
'path' option) or to the filename (for the
'tags' option) with a ';'. If you want several stop-directories separate them with ';'. If you want no stop-directory ("search upward till the root directory") just use ';'.
/usr/include/sys;/usr
will search in:
/usr/include/sys/usr/include/usr
If you use a relative path the upward search is started in Vim's current directory or in the directory of the current file (if the relative path starts with './' and 'd' is not included in
'cpoptions').
If Vim's current path is /u/user_x/work/release and you do
:set path=include;/u/user_x
and then search for a file with
gf the file is searched in:
/u/user_x/work/release/include/u/user_x/work/include/u/user_x/include
Note: If your
'path' setting includes a non-existing directory, Vim will skip the non-existing directory, and also does not search in the parent of the non-existing directory if upwards searching is used.
3) Combined up/downward search: If Vim's current path is /u/user_x/work/release and you do
set path=**;/u/user_x
and then search for a file with
gf the file is searched in:
/u/user_x/work/release/**/u/user_x/work/**/u/user_x/**
BE CAREFUL! This might consume a lot of time, as the search of '/u/user_x/**' includes '/u/user_x/work/**' and '/u/user_x/work/release/**'. So '/u/user_x/work/release/**' is searched three times and '/u/user_x/work/**' is searched twice.
In the above example you might want to set path to:
:set path=**,/u/user_x/**
This searches:
/u/user_x/work/release/**/u/user_x/**
This searches the same directories, but in a different order.
Note that completion for ":find", ":sfind", and ":tabfind" commands do not currently work with
'path' items that contain a URL or use the double star with depth limiter (/usr/**2) or upward search (;) notations.
Nvim executes arbitrary code found on the filesystem if
'exrc' is enabled. Toprevent executing malicious code, only "trusted files" are executed. You canmark a file as trusted or untrusted using the
:trust command or the
vim.secure.read() function.
Manage trusted files. Without ++ options, :trust marksthe current buffer as trusted, keyed on a hash of itscontents. The trust list is stored on disk, Nvim willre-use it after restarting.
[++deny] marks [file] (or current buffer if no [file])as untrusted: it will never be executed,
'exrc' willignore it.
[++remove] removes [file] (or current buffer if no[file]) from the trust list. When the file isdiscovered by
'exrc' or
vim.secure.read(), the userwill be asked whether to trust or deny the file.