0

I'm playing with conceal in help files to highlight / colour specific text strings. This was working fine until I added the :print: example below.

conceal example

Using this concealed all the : as expected so I tried to escape the : around the word print:

:%s/[^[:print:]]//g :

The original conceal statement was:

syntax match myIgnoreHc /[:#]|[#:]/ contained conceal -Oopswrong original
syn match myhelpCommentHc       "[:#]\s.\{-}\s[:#]\s" contains=myIgnoreHc

I changed the match to:

syntax match myIgnoreHc /[:#]\s\S\|\S\s[#:]/ contained conceal 

which worked if I wrote the :print: as : :print :

However I'd prefer to escape or tell the parser to ignore the match in certain situations e.g. :: or ## as the :print : isn't what I was after :).

What I'm trying to achieve

I am using the following to hide the opening and closing elements of the match, see image

syntax match myIgnoreHc /[:#]\s\S\|\S\s[#:]/ contained conceal 
syn match myhelpCommentHc       "[:#]\s.\{-}\s[:#]\s" contains=myIgnoreHc

The : /if line.. example in image does what I want

However if I have a string like

: %s/[[:print:]]//g :

ie second image , then all : are hidden, as expected.

I'm looking for a way to escape the second and third : so they aren't hidden without having to write : %s/[:print:]//g : in the help file like .

: %s/[: :print: :]//g :

in order to achieve the second example

enter image description here

As a workaround I've changed the match command to be

syntax match myIgnoreHc /\^\*\s\|\s\^\*\s/ contained conceal 
syn match myhelpCommentHc   "\^\*\s.*\s\^\*\s" contains=myIgnoreHc

which works until I write help with a second ^* string

enter image description here

Any suggestions?

Note: This post is a copy of the following as I couldn't get an answer there: https://vi.stackexchange.com/questions/5850/escaping-a-character-included-in-a-conceal-command-vimscript.

Community
  • 1
  • 1
Steve
  • 388
  • 1
  • 3
  • 14

0 Answers0