So Vim Patch 8.2.3578 added the ability to get and set the various attributes for highlighting groups in a more efficient manner.
This is strictly speaking not required to check whether or not a highlighting group exists, for which Vim has already before that patch provided a separate VimScript function: hlexists()
So in your case, you can simply test:
if hlexists('SoftWrapHighlightGroup')
" do something
else
" do something else
endif
This function seems to exists for a very long time. I could find it back in Vim 5.1 in the vim-history repository
being documented and before that, the function was just highlight_exists()
.
And Vim 5.1 has been released around April 1998 (!) as you can see here (copied here a condensed table for your information):
Version |
Release-Date |
9.0 |
28th, June 2022 |
8.2 |
12th, December, 2019 |
8.1 |
17th May, 2018 |
8.0 |
12th September, 2016 |
7.4 |
10th August, 2013 |
7.3 |
15th August, 2010 |
7.2 |
9th August, 2008 |
7.1 |
12th May, 2007 |
7.0 |
8th May, 2006 |
6.4 |
15th October, 2005 |
6.3 |
8th June 2004 |
6.2 |
1st June 2003 |
6.1 |
24th March 2002 |
6.0 |
27th September, 2001 |
5.8 |
31st May, 2001 |
5.7 |
24th June, 2000 |
5.6 |
16th January, 2000 |
5.5 |
21st September, 1999 |
5.4 |
26th July, 1999 |
5.3 |
31st August, 1998 |
5.2 |
24th August, 1998 |
5.1 |
7th April, 1998 |
5.0 |
19th February, 1998 |
4.6 |
13th March, 1997 |
4.5 |
17th October, 1996 |
4.2 |
5th July, 1996 |
4.0 |
21st May, 1996 |
3.0 |
16th August, 1994 |
2.0 |
21st December, 1993 |
1.27 |
23rd April, 1993 |
1.24 |
5 Jan 1993 |
1.17 |
21st April, 1992 |
1.14 |
2nd November, 1991 |
->
method script syntax, but that does not seem to be the case. It looks like the problem is the use ofhlget()
which was added in Vim Patch 8.2.3578. But you just want to check for the existence of a highlighting group, for which you can simply usehlexists()
, that should be available even in old vimshlget
not being available in a given version of Vim. Yes, the->
has nothing to do with the problem. As regards whenhlget
was introduced, yeah, I got the patch number wrong. And I didn't know ofhlexists
. This last bit is a actually worth an answer. Feel free to post it and I'll accept.