How to underline a given word

Hi,
I am working my way through codemirror 6 and wondering if it possible to underline a given word within the editor. If so, what would be the easiest way of doing this.

Mark decorations can be used to underline something. See also the decoration example.

Can we also achieve the same functionality in codemirror5?

Yes, see markText.

Hi @marijn,
In addition to the above query can we also show a tooltip to the underline text in codemirror5.

There’s no built-in feature like that. You’ll have to use cursorCoords to find the position to put a DOM element that float over the editor.

Thanks @marijn for the reply,

Also as i want the tooltip to appear on hovering a text, so is there any hover event exposed from codemirror5?

No, that too you’ll have to implement yourself.