热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

codemirror命令详解及使用

2019独角兽企业重金招聘Python工程师标准创建codemirror对象:varmyCodeMirrorCodeMirror(document.body,{

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

创建codemirror对象:

var myCodeMirror = CodeMirror(document.body, {value: "function myScript(){return 100;}\n",mode: "Javascript"
});

命令使用方法示例:

//以下命令的作用是将滚动条置于文本区最下方
codemirror.execCommand("goDocEnd");

如果与angularjs的ui-codemirror模块集成,需要将光标或滚动条置于文本最下方时,则需要在ui-codemirror.js文件中增加命令:

function configNgModelLink(codemirror, ngModel, scope) {if (!ngModel) { return; }// CodeMirror expects a string, so make sure it gets one.// This does not change the model.ngModel.$formatters.push(function(value) {if (angular.isUndefined(value) || value === null) {return '';} else if (angular.isObject(value) || angular.isArray(value)) {throw new Error('ui-codemirror cannot use an object or an array as a model');}return value;});// Override the ngModelController $render method, which is what gets called when the model is updated.// This takes care of the synchronizing the codeMirror element with the underlying model, in the case that it is changed by something else.ngModel.$render = function() {//Code mirror expects a string so make sure it gets one//Although the formatter have already done this, it can be possible that another formatter returns undefined (for example the required directive)var safeViewValue = ngModel.$viewValue || '';codemirror.setValue(safeViewValue);codemirror.execCommand("goDocEnd"); //将光标和滚动条设置到文本区最下方};// Keep the ngModel in sync with changes from CodeMirrorcodemirror.on('change', function(instance) {var newValue = instance.getValue();if (newValue !== ngModel.$viewValue) {scope.$evalAsync(function() {ngModel.$setViewValue(newValue);codemirror.execCommand("goDocEnd");//将光标和滚动条设置到文本区最下方});}});}

其他命令如下,加粗字体命令的均可直接使用:

selectAllCtrl-A (PC), Cmd-A (Mac)

Select the whole content of the editor.

singleSelectionEsc

When multiple selections are present, this deselects all but the primary selection.

killLineCtrl-K (Mac)

Emacs-style line killing. Deletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted.

deleteLineCtrl-D (PC), Cmd-D (Mac)

Deletes the whole line under the cursor, including newline at the end.

delLineLeft

Delete the part of the line before the cursor.

delWrappedLineLeftCmd-Backspace (Mac)

Delete the part of the line from the left side of the visual line the cursor is on to the cursor.

delWrappedLineRightCmd-Delete (Mac)

Delete the part of the line from the cursor to the right side of the visual line the cursor is on.

undoCtrl-Z (PC), Cmd-Z (Mac)

Undo the last change.

redoCtrl-Y (PC), Shift-Cmd-Z (Mac), Cmd-Y (Mac)

Redo the last undone change.

undoSelectionCtrl-U (PC), Cmd-U (Mac)

Undo the last change to the selection, or if there are no selection-only changes at the top of the history, undo the last change.

redoSelectionAlt-U (PC), Shift-Cmd-U (Mac)

Redo the last change to the selection, or the last text change if no selection changes remain.

goDocStartCtrl-Home (PC), Cmd-Up (Mac), Cmd-Home (Mac)

Move the cursor to the start of the document.

goDocEndCtrl-End (PC), Cmd-End (Mac), Cmd-Down (Mac)

Move the cursor to the end of the document.

goLineStartAlt-Left (PC), Ctrl-A (Mac)

Move the cursor to the start of the line.

goLineStartSmartHome

Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).

goLineEndAlt-Right (PC), Ctrl-E (Mac)

Move the cursor to the end of the line.

goLineRightCmd-Right (Mac)

Move the cursor to the right side of the visual line it is on.

goLineLeftCmd-Left (Mac)

Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.

goLineLeftSmart

Move the cursor to the left side of the visual line it is on. If that takes it to the start of the line, behave like goLineStartSmart.

goLineUpUp, Ctrl-P (Mac)

Move the cursor up one line.

goLineDownDown, Ctrl-N (Mac)

Move down one line.

goPageUpPageUp, Shift-Ctrl-V (Mac)

Move the cursor up one screen, and scroll up by the same distance.

goPageDownPageDown, Ctrl-V (Mac)

Move the cursor down one screen, and scroll down by the same distance.

goCharLeftLeft, Ctrl-B (Mac)

Move the cursor one character left, going to the previous line when hitting the start of line.

goCharRightRight, Ctrl-F (Mac)

Move the cursor one character right, going to the next line when hitting the end of line.

goColumnLeft

Move the cursor one character left, but don't cross line boundaries.

goColumnRight

Move the cursor one character right, don't cross line boundaries.

goWordLeftAlt-B (Mac)

Move the cursor to the start of the previous word.

goWordRightAlt-F (Mac)

Move the cursor to the end of the next word.

goGroupLeftCtrl-Left (PC), Alt-Left (Mac)

Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character.

goGroupRightCtrl-Right (PC), Alt-Right (Mac)

Move to the right of the group after the cursor (see above).

delCharBeforeShift-Backspace, Ctrl-H (Mac)

Delete the character before the cursor.

delCharAfterDelete, Ctrl-D (Mac)

Delete the character after the cursor.

delWordBeforeAlt-Backspace (Mac)

Delete up to the start of the word before the cursor.

delWordAfterAlt-D (Mac)

Delete up to the end of the word after the cursor.

delGroupBeforeCtrl-Backspace (PC), Alt-Backspace (Mac)

Delete to the left of the group before the cursor.

delGroupAfterCtrl-Delete (PC), Ctrl-Alt-Backspace (Mac), Alt-Delete (Mac)

Delete to the start of the group after the cursor.

indentAutoShift-Tab

Auto-indent the current line or selection.

indentMoreCtrl-] (PC), Cmd-] (Mac)

Indent the current line or selection by one indent unit.

indentLessCtrl-[ (PC), Cmd-[ (Mac)

Dedent the current line or selection by one indent unit.

insertTab

Insert a tab character at the cursor.

insertSoftTab

Insert the amount of spaces that match the width a tab at the cursor position would have.

defaultTabTab

If something is selected, indent it by one indent unit. If nothing is selected, insert a tab character.

transposeCharsCtrl-T (Mac)

Swap the characters before and after the cursor.

newlineAndIndentEnter

Insert a newline and auto-indent the new line.

toggleOverwriteInsert

Flip the overwrite flag.

saveCtrl-S (PC), Cmd-S (Mac)

Not defined by the core library, only referred to in key maps. Intended to provide an easy way for user code to define a save command.

findCtrl-F (PC), Cmd-F (Mac)

findNextCtrl-G (PC), Cmd-G (Mac)

findPrevShift-Ctrl-G (PC), Shift-Cmd-G (Mac)

replaceShift-Ctrl-F (PC), Cmd-Alt-F (Mac)

replaceAllShift-Ctrl-R (PC), Shift-Cmd-Alt-F (Mac)


转:https://my.oschina.net/u/2391658/blog/789632



推荐阅读
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • Iamtryingtocreateanarrayofstructinstanceslikethis:我试图创建一个这样的struct实例数组:letinstallers: ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • imx6ull开发板驱动MT7601U无线网卡的方法和步骤详解
    本文详细介绍了在imx6ull开发板上驱动MT7601U无线网卡的方法和步骤。首先介绍了开发环境和硬件平台,然后说明了MT7601U驱动已经集成在linux内核的linux-4.x.x/drivers/net/wireless/mediatek/mt7601u文件中。接着介绍了移植mt7601u驱动的过程,包括编译内核和配置设备驱动。最后,列举了关键词和相关信息供读者参考。 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • Python爬虫中使用正则表达式的方法和注意事项
    本文介绍了在Python爬虫中使用正则表达式的方法和注意事项。首先解释了爬虫的四个主要步骤,并强调了正则表达式在数据处理中的重要性。然后详细介绍了正则表达式的概念和用法,包括检索、替换和过滤文本的功能。同时提到了re模块是Python内置的用于处理正则表达式的模块,并给出了使用正则表达式时需要注意的特殊字符转义和原始字符串的用法。通过本文的学习,读者可以掌握在Python爬虫中使用正则表达式的技巧和方法。 ... [详细]
  • 本文介绍了pack布局管理器在Perl/Tk中的使用方法及注意事项。通过调用pack()方法,可以控制部件在显示窗口中的位置和大小。同时,本文还提到了在使用pack布局管理器时,应注意将部件分组以便在水平和垂直方向上进行堆放。此外,还介绍了使用Frame部件或Toplevel部件来组织部件在窗口内的方法。最后,本文强调了在使用pack布局管理器时,应避免在中间切换到grid布局管理器,以免造成混乱。 ... [详细]
author-avatar
dasda
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有