热门标签 | 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



推荐阅读
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 本文介绍了在Windows环境下使用pydoc工具的方法,并详细解释了如何通过命令行和浏览器查看Python内置函数的文档。此外,还提供了关于raw_input和open函数的具体用法和功能说明。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 在前两篇文章中,我们探讨了 ControllerDescriptor 和 ActionDescriptor 这两个描述对象,分别对应控制器和操作方法。本文将基于 MVC3 源码进一步分析 ParameterDescriptor,即用于描述 Action 方法参数的对象,并详细介绍其工作原理。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文详细分析了Hive在启动过程中遇到的权限拒绝错误,并提供了多种解决方案,包括调整文件权限、用户组设置以及环境变量配置等。 ... [详细]
  • 本文详细介绍了macOS系统的核心组件,包括如何管理其安全特性——系统完整性保护(SIP),并探讨了不同版本的更新亮点。对于使用macOS系统的用户来说,了解这些信息有助于更好地管理和优化系统性能。 ... [详细]
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • 使用Python在SAE上开发新浪微博应用的初步探索
    最近重新审视了新浪云平台(SAE)提供的服务,发现其已支持Python开发。本文将详细介绍如何利用Django框架构建一个简单的新浪微博应用,并分享开发过程中的关键步骤。 ... [详细]
  • 本文详细介绍如何使用arm-eabi-gdb调试Android平台上的C/C++程序。通过具体步骤和实用技巧,帮助开发者更高效地进行调试工作。 ... [详细]
  • 计算机网络复习:第五章 网络层控制平面
    本文探讨了网络层的控制平面,包括转发和路由选择的基本原理。转发在数据平面上实现,通过配置路由器中的转发表完成;而路由选择则在控制平面上进行,涉及路由器中路由表的配置与更新。此外,文章还介绍了ICMP协议、两种控制平面的实现方法、路由选择算法及其分类等内容。 ... [详细]
  • 本文详细介绍了如何解决Uploadify插件在Internet Explorer(IE)9和10版本中遇到的点击失效及JQuery运行时错误问题。通过修改相关JavaScript代码,确保上传功能在不同浏览器环境中的一致性和稳定性。 ... [详细]
  • 本文介绍了一款用于自动化部署 Linux 服务的 Bash 脚本。该脚本不仅涵盖了基本的文件复制和目录创建,还处理了系统服务的配置和启动,确保在多种 Linux 发行版上都能顺利运行。 ... [详细]
  • MongoDB集群配置:副本集与分片详解
    本文详细介绍了如何在MongoDB中配置副本集(Replica Sets)和分片(Sharding),并提供了具体的步骤和命令,帮助读者理解并实现高可用性和水平扩展的MongoDB集群。 ... [详细]
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社区 版权所有