Professional Documents
Culture Documents
Notepad++ Cheat Sheet
Notepad++ Cheat Sheet
Home
PUBLIC
CodeMirror AutoComplete Custom List
Stack OverflowAsk Question
Log In Sign Up
TEAMS
Looking for a job?
Create Team 2
I am having a bit of difficultly re the auto complete function in code mirror. What I am trying to do is Senior/Lead .Net Developer (full stack)
two things (both which I am struggling with): Simplicity First Solutions, LLC Pune, India
c# .net
1) I want to enable auto complete for both HTML and JavaScript . Currently I can only get one
working at a time using e.g.:
Family-Friendly team seeks Junior/Mid-
CodeMirror.commands.autocomplete = function (cm) { Level Developer (JavaScript NodeJS
CodeMirror.showHint(cm, CodeMirror.hint.html); React)
}; Spidergap No office location
£20K - £40K REMOTE
How can I add the CodeMirror.hint.javascript to the list from the HTML one? javascript html
2) (Kind of more important) -- How can I add custom variables to the list of hints from HTML
Short Term Contract Xamarin Hybrid
which area retrieved from an ajax call..... Shell App Developer
PalabraApps No office location
i.e. I want to have the drop down show up with the current list of data from the html hints, but then
$60K - $96K REMOTE
add custom entries such as ##SomeCode1## and ##SomeCode2##
xamarin asp.net-mvc-4
I have two problems here. First when I try to hard code the values in the 'html-hint.js' file the values
all get appended with < ... which is not what I want. Senior C# Web Developer (work from
home!)
The second problem, kind of, is that I believe I have to write a new 'html-hint.js' file correct? I mean Powerfront Pty Ltd No office location
there is no way to pass anything in the 'options' parameter in the CodeMirror.hint.html above is $12K - $36K REMOTE
there, to essentially merge two list. c# .net
I guest one and two are kind of the same come to think of it... Merging two lists of values for auto
complete together.
Linked
I am guessing there is nothing already in the framework and I have to write a custom hint file,
correct? 4 Writing a custom mode for CodeMirror, for
use in Brackets
Any pointers would be appreciated. Sample code would be awesome. 7 CodeMirror custom hint list not working
properly
codemirror
2 Live autocomplete in Codemirror
share improve this question
0 ng2-codemirror - How to add custom
edited Jul 8 '16 at 14:53
keywords to autocomplete (hint)
WMios
6,255 9 33 57 0 Overwriting a Javascript function in
Typescript
asked Oct 8 '13 at 9:51
Robin Rieger Related
849 1 11 29
+1 for bozo you jabroni! – Dänu Sep 19 '14 at 14:02 How can we find a dog to "test drive"?
Marijn, the code above doesn't work as expected. The word 'bozo' is indeed added to the list, but as I type 'b- How to avoid the language barrier when there is
o-z...' it is not selected. On the contrary, if my page has a function named 'monkey,' as I type 'm-o-n...' that no time to learn the other language?
name is indeed selected. Also, the word 'bozo' is always displayed, not just when the user types a similar Anagrams: From Food to Food
word. This is not the expected behavior for autocompletion. Are there any other ways to accomplish this? –
shmim May 20 '16 at 18:54 How do I bend a line onto a circle?
p.s. Don't forget to change hint with yours, since I'm using javascript I've changed javascript hint. Why do two identical lists have a different
memory footprint?
CodeMirror.hint.javascript = function (editor) {
var list = Session.get(Template.strSessionDistinctFields) || []; question feed
var cursor = editor.getCursor();
var currentLine = editor.getLine(cursor.line);
var start = cursor.ch;
var end = start;
while (end < currentLine.length && /[\w$]+/.test(currentLine.charAt(end))) ++end;
while (start && /[\w$]+/.test(currentLine.charAt(start ‐ 1))) ‐‐start;
var curWord = start != end && currentLine.slice(start, end);
var regex = new RegExp('^' + curWord, 'i');
var result = {
list: (!curWord ? list : list.filter(function (item) {
return item.match(regex);
})).sort(),
from: CodeMirror.Pos(cursor.line, start),
to: CodeMirror.Pos(cursor.line, end)
};
return result;
};
Is it possible to add custom hint list only to a certain CodeMirror instance? – peterremec Dec 5 '16 at 11:39
ofc, in that case you need to create your own mode for codemirror, stackoverflow.com/questions/24433552/
… – Sercan Ozdemir Dec 5 '16 at 11:51
I'm not sure if we understand each other. I have two CodeMirror "sql mode" instances on a page with
autocomplete function on. I need to add some custom keywords in addition to a built-in sql keywords. I don't
understand why should I create a new mode. Besides that I'm looking for a way to dynamically add / remove
keywords from that list – peterremec Dec 5 '16 at 12:46
No problem, thank you for your response. – peterremec Dec 5 '16 at 13:43
no you need to escape per special charachter when they come from user input for example for the @ sign
you need to write it like \@ before giving into RegExp constructor – Sercan Ozdemir Oct 17 '17 at 7:17
Your Answer
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie
policy, and that your continued use of the website is subject to these policies.
Not the answer you're looking for? Browse other questions tagged codemirror or ask your own question.
STACK OVERFLOW
Questions
Jobs
Developer Jobs Directory
Salary Calculator
Help
Mobile
Disable Responsiveness
PRODUCTS
Teams
Talent
Engagement
Enterprise
COMPANY
About
Press
Work Here
Legal
Privacy Policy
Contact Us
STACK EXCHANGE
NETWORK
Technology
Life / Arts
Culture / Recreation
Science
Other
Blog
LinkedIn
site design / logo © 2018 Stack Exchange Inc; user contributions licensed under cc by-sa 3.0 with attribution required. rev 2018.7.26.31180