Fix example in help for :try

11 views
Skip to first unread message

Shane Harper

unread,
Feb 18, 2020, 1:59:10 AM2/18/20
to vim_dev
The first example in the help for :try is incorrect:
:try | edit too much | finally | echo "cleanup" | endtry
:echo "impossible" " not reached, script terminated above
"impossible" is now output.

It used to work prior to patch 8.0.1189 on Unix; "edit too much" would have caused "E172: Only one file name allowed".

A possible fix is to replace the first line with
                :try | call items("invalid argument") | finally | echo "cleanup" | endtry

Bram Moolenaar

unread,
Feb 18, 2020, 3:33:45 PM2/18/20
to vim...@googlegroups.com, Shane Harper
A bit shorter:

try | call Unknown() | finally | echomsg "cleanup" | endtry
echomsg "not reached"

This uses "echomsg" so that ":messages" shows the output again.

It actually also didn't work until the recent fix for finding the "|".


--
Warning label on a superhero Halloween costume:
"Caution: Cape does not enable user to fly."

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages