If I have syntax highlighting rules setup using conceal to hide or change certain characters in a file, how do I search what is displayed, as opposed to what the buffer actually contains?

The concealed part may contain formatting markup, for example, which I wish to ignore.

I'd like a method that:

  • doesn't rely on the specific rules used to create the concealed text.
  • provides some level of compatibility with the traditional search operators like n, *, etc.

Can this be done without re-implementing n, * and the like?



1 Answer 1


This is not really possible, as concealing was meant as a sole method for displaying chars instead of the actual content. In the same sense, you can't really search for what has been folded or signs. The only method I know is using screenchar() function as shown in my other answer, but that is not really ready to use.

  • While it's true I can't search for what has been folded, by using 'foldopen', I can tell Vim to match at most once in a folded region, so there are small steps in that direction. Anyway, what's the stance on conceal? Is there hope of seeing such functionality implemented?
    – muru
    Commented Jun 6, 2016 at 17:32
  • true, but you still couldn't search for what is returned by foldtext(). Anyways, you might want to suggest an improvement at vim-dev ml and see what Bram thinks, but my feeling is, this won't be implemented anytime soon since there are still too many bugs/particularities with conceal mode today and nobody really looked for fixing it. I did try once, but it was complicated and broke in subtle ways. Commented Jun 6, 2016 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.