Autocompletion for {},[],() in latex envs invalidate those autocompletion of codemirror.
So {},[],() should be deleted from the variable: array_completion.
I add smartbackspace for "$$":
//smart delete for $.
if (event.key == "Backspace") {
var ran = {
line: cur.line,
ch: cur.ch - 1
}
var ran2 = {
line: cur.line,
ch: cur.ch - 2
}
var ran3 = {
line: cur.line,
ch: cur.ch + 1
}
var pre1ch = editor.getRange(ran, cur);
var pre2ch = editor.getRange(ran2, cur);
var pos1ch = editor.getRange(cur,ran3);
if(pre1ch == "$"){
if (pos1ch == "$") {
editor.replaceRange("", cur, ran3);
return true
}
if (pre2ch == "$$"||pre2ch == "\\$") {
var ran0 = {
line: cur.line,
ch: cur.ch - 1
}
editor.replaceRange("", ran0, cur);
return true
}
}
}
I also add an keymap for autocompletion for environments:
cmds[map["Ctrl-L E"] = "Environment"] = function(cm)
{
var cur
if(cm.somethingSelected()){
var env=cm.getSelection()
cm.replaceSelection("")
}
else{
cur=cm.getCursor()
cm.moveH(-1, "char")
var word = cm.findWordAt(cm.getCursor())
cm.moveH(1, "char")
var env=cm.getRange(word.anchor, word.head)
env=env.trim()
if(env !=""){
cm.setSelection(word.anchor,word.head)
}
}
cm.replaceSelection("\\begin{"+env+"}\n\n\\end{"+env+"}")
if(env !=""){
cm.moveV(-1, "line")
}
else{
var line=cur.line
var curpos=cur.ch
var c=[
{anchor:{line:line,ch:curpos+7},head:{line:line,ch:curpos+7}},
{anchor:{line:line+2,ch:5},head:{line:line+2,ch:5}}
]
cm.setSelections(c)
}
return false;
};
Autocompletion for {},[],() in latex envs invalidate those autocompletion of codemirror. So {},[],() should be deleted from the variable: array_completion. I add smartbackspace for "$$":
I also add an keymap for autocompletion for environments:
I tyr to add autocompletion for latex command for \alpha, \beta,...., as the way in: https://ejgallego.github.io/CodeMirror-TeX-input/demo/tex-input.html But I can not make it work by desired way. I am not familiar with javascript in jupyter notebook.
Can you give me some help? Thanks!