Home Explore Blog CI



neovim

29th chunk of `runtime/doc/vimeval.txt`
ffa52d76023256529095908723c05edab59789bad098ae8e0000000100000fa0
 until the matching `:endtry`
			are executed whenever the part between the matching
			`:try` and the `:finally` is left:  either by falling
			through to the `:finally` or by a `:continue`,
			`:break`, `:finish`, or `:return`, or by an error or
			interrupt or exception (see `:throw`).

							*:th* *:throw* *E608*
:th[row] {expr1}	The {expr1} is evaluated and thrown as an exception.
			If the `:throw` is used after a `:try` but before the
			first corresponding `:catch`, commands are skipped
			until the first `:catch` matching {expr1} is reached.
			If there is no such `:catch` or if the `:throw` is
			used after a `:catch` but before the `:finally`, the
			commands following the `:finally` (if present) up to
			the matching `:endtry` are executed.  If the `:throw`
			is after the `:finally`, commands up to the `:endtry`
			are skipped.  At the `:endtry`, this process applies
			again for the next dynamically surrounding `:try`
			(which may be found in a calling function or sourcing
			script), until a matching `:catch` has been found.
			If the exception is not caught, the command processing
			is terminated.
			Example: >
		:try | throw "oops" | catch /^oo/ | echo "caught" | endtry
<			Note that "catch" may need to be on a separate line
			for when an error causes the parsing to skip the whole
			line and not see the "|" that separates the commands.

							*:ec* *:echo*
:ec[ho] {expr1} ..	Echoes each {expr1}, with a space in between.  The
			first {expr1} starts on a new line.
			Also see |:comment|.
			Use "\n" to start a new line.  Use "\r" to move the
			cursor to the first column.
			Uses the highlighting set by the `:echohl` command.
			Cannot be followed by a comment.
			Example: >
		:echo "the value of 'shell' is" &shell
<							*:echo-redraw*
			A later redraw may make the message disappear again.
			And since Vim mostly postpones redrawing until it's
			finished with a sequence of commands this happens
			quite often.  To avoid that a command from before the
			`:echo` causes a redraw afterwards (redraws are often
			postponed until you type something), force a redraw
			with the `:redraw` command.  Example: >
		:new | redraw | echo "there is a new window"
<							*:echo-self-refer*
			When printing nested containers echo prints second
			occurrence of the self-referencing container using
			"[...@level]" (self-referencing |List|) or
			"{...@level}" (self-referencing |Dict|): >
		:let l = []
		:call add(l, l)
		:let l2 = []
		:call add(l2, [l2])
		:echo l l2
<			echoes "[[...@0]] [[[...@0]]]". Echoing "[l]" will
			echo "[[[...@1]]]" because l first occurs at second
			level.

							*:echon*
:echon {expr1} ..	Echoes each {expr1}, without anything added.  Also see
			|:comment|.
			Uses the highlighting set by the `:echohl` command.
			Cannot be followed by a comment.
			Example: >
				:echon "the value of 'shell' is " &shell
<
			Note the difference between using `:echo`, which is a
			Vim command, and `:!echo`, which is an external shell
			command: >
		:!echo %		--> filename
<			The arguments of ":!" are expanded, see |:_%|. >
		:!echo "%"		--> filename or "filename"
<			Like the previous example.  Whether you see the double
			quotes or not depends on your 'shell'. >
		:echo %			--> nothing
<			The '%' is an illegal character in an expression. >
		:echo "%"		--> %
<			This just echoes the '%' character. >
		:echo expand("%")	--> filename
<			This calls the expand() function to expand the '%'.

							*:echoh* *:echohl*
:echoh[l] {name}	Use the highlight group {name} for the following
			`:echo`, `:echon` and `:echomsg` commands.  Also used
			for the `input()` prompt.  Example: >
		:echohl WarningMsg | echo "Don't panic!" | echohl None
<			Don't forget to set the group back to "None",
			otherwise all following echo's will be highlighted.

							*:echom* *:echomsg*
:echom[sg] {expr1} ..	Echo the expression(s) as a true message, saving the
			message in the |message-history|.
			Spaces are placed between

Title: Vim Script: Exception Handling and Echo Commands
Summary
This section elaborates on exception handling in Vim script using ':finally' and ':throw'. It details how ':finally' ensures commands are executed when leaving a ':try' block. It covers ':throw', explaining how exceptions are raised and caught, including the search process for matching ':catch' blocks. The section then transitions to echo commands: ':echo' for displaying expressions with spaces and newlines, ':echon' for displaying expressions without additions, and ':echohl' for setting highlight groups for echo commands. Finally, it introduces ':echomsg' for echoing expressions as messages, saving them in the message history.