question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Find string in Codemirror without Dialog

See original GitHub issue

Hi.

How do I trigger the search in CodeMirror to select(and unselect) a specific string without using the dialog?

I am looking for something like: CodeMirror.execCommand('find', 'test') and it will mark all occurences of test just like it would when I use the dialog box.

I found a duplicate of this: https://github.com/codemirror/CodeMirror/issues/3392 but it has been closed with a hint to https://codemirror.net/doc/manual.html#addon_searchcursor and I really can’t see at all how I would implement this via getSearchCursor(). Can someone provide an example for this or has some additional explanations?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Xatenevcommented, Aug 13, 2018

Thanks your right. It works now. I think a doc entry for this might be helpful.

FWIW the full working code is:

 let cursor = this.cm.getSearchCursor(val);
 cursor.findNext();
 this.cm.setSelection(cursor.from(), cursor.to());
0reactions
marijnhcommented, Aug 13, 2018

You didn’t move the cursor to a match yet, so from and to aren’t returning anything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find string in Codemirror without Dialog · Issue #5521 - GitHub
Hi. How do I trigger the search in CodeMirror to select(and unselect) a specific string without using the dialog?
Read more >
codemirror: search and highlight multipule words without dialog
Search and highlight multiple strings · I want to be able to iterate each number of matches found and print its line number....
Read more >
Search/Replace Demo - CodeMirror
Persistent search (dialog doesn't autoclose, enter to find next, Shift-Enter to find previous); Alt-G: Jump to line. Searching is enabled by including addon/ ......
Read more >
CodeMirror 5 User Manual
It may be a string, which either simply names the mode or is a MIME type associated with the mode. The value "null"...
Read more >
Reference Manual - CodeMirror
Look up a translation for the given phrase (via the phrases facet), or return the original string if no translation is found.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found