Home Explore Blog CI



neovim

79th chunk of `runtime/doc/options.txt`
b983a911ae7b6dc35bff5f071d6c337ab28972ebb59607720000000100000fa6
 line flag.  The |--clean|
	command line flag sets it to "NONE".
	This option cannot be set from a |modeline| or in the |sandbox|, for
	security reasons.

						*'shell'* *'sh'* *E91*
'shell' 'sh'		string	(default $SHELL or "sh", Win32: "cmd.exe")
			global
	Name of the shell to use for ! and :! commands.  When changing the
	value also check these options: 'shellpipe', 'shellslash'
	'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag'.
	It is allowed to give an argument to the command, e.g.  "csh -f".
	See |option-backslash| about including spaces and backslashes.
	Environment variables are expanded |:set_env|.

	If the name of the shell contains a space, you need to enclose it in
	quotes.  Example with quotes: >vim
		set shell=\"c:\program\ files\unix\sh.exe\"\ -f
<	Note the backslash before each quote (to avoid starting a comment) and
	each space (to avoid ending the option value), so better use |:let-&|
	like this: >vim
		let &shell='"C:\Program Files\unix\sh.exe" -f'
<	Also note that the "-f" is not inside the quotes, because it is not
	part of the command name.
							*shell-unquoting*
	Rules regarding quotes:
	1. Option is split on space and tab characters that are not inside
	   quotes: "abc def" runs shell named "abc" with additional argument
	   "def", '"abc def"' runs shell named "abc def" with no additional
	   arguments (here and below: additional means “additional to
	   'shellcmdflag'”).
	2. Quotes in option may be present in any position and any number:
	   '"abc"', '"a"bc', 'a"b"c', 'ab"c"' and '"a"b"c"' are all equivalent
	   to just "abc".
	3. Inside quotes backslash preceding backslash means one backslash.
	   Backslash preceding quote means one quote. Backslash preceding
	   anything else means backslash and next character literally:
	   '"a\\b"' is the same as "a\b", '"a\\"b"' runs shell named literally
	   'a"b', '"a\b"' is the same as "a\b" again.
	4. Outside of quotes backslash always means itself, it cannot be used
	   to escape quote: 'a\"b"' is the same as "a\b".
	Note that such processing is done after |:set| did its own round of
	unescaping, so to keep yourself sane use |:let-&| like shown above.
							*shell-powershell*
	To use PowerShell: >vim
		let &shell = executable('pwsh') ? 'pwsh' : 'powershell'
		let &shellcmdflag = '-NoLogo -NonInteractive -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';$PSStyle.OutputRendering=''plaintext'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;'
		let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode'
		let &shellpipe  = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode'
		set shellquote= shellxquote=

<	This option cannot be set from a |modeline| or in the |sandbox|, for
	security reasons.

						*'shellcmdflag'* *'shcf'*
'shellcmdflag' 'shcf'	string	(default "-c"; Windows: "/s /c")
			global
	Flag passed to the shell to execute "!" and ":!" commands; e.g.,
	`bash.exe -c ls` or `cmd.exe /s /c "dir"`.  For MS-Windows, the
	default is set according to the value of 'shell', to reduce the need
	to set this option by the user.
	On Unix it can have more than one flag.  Each white space separated
	part is passed as an argument to the shell command.
	See |option-backslash| about including spaces and backslashes.
	See |shell-unquoting| which talks about separating this option into
	multiple arguments.
	This option cannot be set from a |modeline| or in the |sandbox|, for
	security reasons.

						*'shellpipe'* *'sp'*
'shellpipe' 'sp'	string	(default ">", "| tee", "|& tee" or "2>&1| tee")
			global
	String to be used to put the output of the ":make" command in the
	error file.  See also |:make_makeprg|.  See |option-backslash| about
	including spaces and backslashes.
	The name of the temporary file can be represented by "%s" if necessary
	(the file name is appended automatically if no %s appears in the value
	of

Title: Vim Options: 'shell', 'shellcmdflag' and 'shellpipe'
Summary
This section delves into the 'shell' option, explaining how to specify the shell used for external commands, including how to handle spaces and quotes in the shell name. It provides rules for unquoting the shell option and an example for using PowerShell. It then discusses the 'shellcmdflag' option, which defines the flags passed to the shell for executing commands, and the 'shellpipe' option, which specifies how the output of the ':make' command is directed to the error file. These options cannot be set from a modeline or sandbox for security reasons.