Home Explore Blog CI



neovim

18th chunk of `runtime/doc/editing.txt`
d697f480b6b80988cd73073ed0de7230c20d2c1a6836c3450000000100000fa4
 *E338* *E614* *E615* *E616*
: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 edit`
			works if the FileExplorer autocommand group exists.
			When ":browse" is not possible you get an error
			message.  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 the
		file chosen. >
	:browse e
<		Open the browser in the directory specified with 'browsedir',
		and edit the file chosen. >
	:browse w
<		Open the browser in the directory of the current buffer,
		with the current buffer filename as default, and save the
		buffer under the filename chosen. >
	:browse w C:/bar
<		Open the browser in the C:/bar directory, with the current
		buffer filename as default, and save the buffer under the
		filename chosen.
Also see the 'browsedir' option.
For versions of Vim where browsing is not supported, the command is executed
unmodified.

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

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

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

You can override the filter setting on a per-buffer basis by setting the
b:browsefilter variable.  You would most likely set b:browsefilter in a
filetype plugin, so that the browse dialog would contain entries related to
the type of file you are currently editing.  Disadvantage: This makes it
difficult to start editing a file of a different type.  To overcome this, you
may want to add >

	All Files\t(*.*)\t*\n
<
as the final filter on Windows or >

	All Files\t(*)\t*\n
<
on other platforms, so that the user can still access any desired file.

To avoid setting browsefilter when Vim does not actually support it, you can
use has("browsefilter"): >

	if has("browsefilter")
	   let g:browsefilter = "whatever"
	endif

==============================================================================
7. The current directory				*current-directory*

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

There are three current-directory "scopes": global, tab and window.  The
window-local working directory takes precedence over the tab-local
working directory, which in turn takes precedence over the global
working directory.  If a local working directory (tab or window) does not
exist, the next-higher scope in the hierarchy applies.

							*:cd* *E747* *E472*
:cd[!]			On non-Unix systems when 'cdhome' is off: Print the
			current directory name.
			Otherwise: Change the current directory to the home
			directory.  Clear any window-local directory.
			Use |:pwd| to print the current directory on all
			systems.

:cd[!] {path}		Change the current

Title: Vim: Browse Command and Current Directory
Summary
This section details the `:browse` command, which opens a file selection dialog for various commands like :e, :w, and :qall. It explains how the dialog's behavior can be customized using the 'browsedir' option and the g:browsefilter/b:browsefilter variables for MS-Windows, which allow modifying the filters used in the browse dialog. The section also covers commands for managing the current directory in Vim, including :cd, :tcd, and :lcd, and explains the concept of global, tab, and window-local working directories and how they interact.