6

It seems that Codemirror plugin show-hint is activated by shortcut. I need to implement live autocomplete functionality, i.e. show hints after user entered first letters of keyword. Is there a way to do this with Codemirror?

Eugene Krakos
  • 159
  • 1
  • 8

2 Answers2

2

Yes, there is a way to do this with CodeMirror. You can see the description of the addon for this here. CodeMirror offers the hint/show-hint.js addon that allows you to display hints when a keyboard short-cut is used.

You can find additional information on adding hints in this StackOverflow question as well.

Additionally, you can checkout their demo here.

mootrichard
  • 3,581
  • 13
  • 25
  • I know that I can do this with shortcut, but I need autocomplete to appear when I start typing keyword, like in monaco editor https://microsoft.github.io/monaco-editor/playground.html (just start typing anything in right editor) – Eugene Krakos Jan 30 '18 at 07:11
  • In that case, just use the Keymaps to activate `show-hint` http://codemirror.net/doc/manual.html#keymaps and just have a very permissive set of Keymaps. – mootrichard Jan 30 '18 at 19:59
0

You could have a function that is fired off after a keyup event. An example of an implementation is in this Stack Overflow answer.

Battlesquid
  • 302
  • 1
  • 10