Add a fake (without any use) caret


I got two questions:

1. I want to show another caret (with a given offset) in a different color and that I can update for any position. How is that possible?

2. What is the fastest or most effective way to receive caret position offset for every caret change?



  1. There is no API to introduce fake caret. What is your use case? We will try to suggest you some approach.
  2. Consider com.intellij.openapi.editor.event.CaretListener.caretPositionChanged() (see its limitation in JavaDoc).

For the first question, I would like to get an offset for a caret (let's say I got it from function caretPositionChanged()) and draw in this offset some type of rectangle or any sign that will show the user there is a caret there. It might remind Google Docs, the sign of other users typing is the thing I am trying to implement here.


For the second question, it might be the thing I am looking for, thanks! 


Hi Ilan,

It sounds like you try to implement something similar to the Code With Me feature available in IDEA: Maybe there is no need to implement your feature at all if Code With Me covers it.

If you need to do something else, please take a look at the following APIs:

  • com.intellij.openapi.editor.Editor.getInlineModel()
  • com.intellij.openapi.editor.Inlay and com.intellij.openapi.editor.EditorCustomElementRenderer

You can implement your EditorCustomElementRenderer drawing a cursor you need.


Please sign in to leave a comment.