启用换行时,如何在 Ace 编辑器中禁用后续行的缩进
How to disable indentation of subsequent lines in Ace Editor when line wrapping is enabled
我有以下代码:
var editor = ace.edit("editor");
editor.setTheme("ace/theme/dreamweaver");
editor.setShowPrintMargin(false);
var session = editor.getSession();
session.setMode("ace/mode/html");
session.setUseWrapMode(true);
.ace_editor {
position: absolute !important;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
<script src="https://cdn.jsdelivr.net/g/ace@1.2.3(min/ace.js+min/mode-html.js+min/theme-dreamweaver.js)" type="text/javascript"></script>
<textarea id="editor"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Pellentesque sed enim vel turpis euismod tristique nec vitae odio. Fusce eu nisi vel ligula vehicula ornare.</p>
<p>Phasellus ornare purus et ultrices dapibus. Donec ullamcorper dapibus quam non imperdiet.</p></textarea>
如您所见,太长的行被正确地换行到下一行,但由于某种原因,换行部分前面有一些奇怪的缩进。我怎样才能摆脱它?
您需要将
选项indentedSoftWrap
设置为在session
上false
,然后再调用setUseWrapMode
。请参阅下面的工作示例:
var editor = ace.edit("editor");
editor.setTheme("ace/theme/dreamweaver");
editor.setShowPrintMargin(false);
var session = editor.getSession();
session.setMode("ace/mode/html");
// Setting the option
session.setOption('indentedSoftWrap', false);
session.setUseWrapMode(true);
.ace_editor {
position: absolute !important;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
<script src="https://cdn.jsdelivr.net/g/ace@1.2.3(min/ace.js+min/mode-html.js+min/theme-dreamweaver.js)" type="text/javascript"></script>
<textarea id="editor"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Pellentesque sed enim vel turpis euismod tristique nec vitae odio. Fusce eu nisi vel ligula vehicula ornare.</p>
<p>Phasellus ornare purus et ultrices dapibus. Donec ullamcorper dapibus quam non imperdiet.</p></textarea>
它最初被称为indentSubsequentLines
[1](在我看来 - 会更有意义),但在登陆插件的代码库之前它被更改了[2]。
相关文章:
- ExtJS网格单元格编辑器,防止焦点松动问题
- 可以't使用PHP使用Froala编辑器上传图像URL
- 如何在corona sdk中从CK编辑器中检索数据
- Eclipse编辑器中无法访问的代码
- 如何将拼写检查集成到密文编辑器
- 一个页面上有多个Ace编辑器,没有预先设置元素
- ACE编辑器正在删除模块,因为define是't一根绳子
- 如何从DOM中删除Aloha编辑器
- 用于用户内容的简单代码编辑器/文本格式化程序(在Rails中)
- 在plone 5中将自定义的灵活性内容类型插入到tinymce编辑器中
- 如何在tinymce编辑器中将点击事件绑定到html标签
- Redactor文本编辑器– 在代码视图中重新缩进缩小的HTML
- 剑道编辑器 - 缩略图 URL 的功能不起作用
- 如何在内容可编辑列表项(不同缩进)之间移动插入符号,同时保持插入符号 x 偏移量
- 设置Ace编辑器的值时保留缩进
- Aptana编辑器显示奇怪的字符-缩进
- Jquery内容可编辑缩进
- Tinymce 制表器缩进
- 启用换行时,如何在 Ace 编辑器中禁用后续行的缩进
- 如何在编辑器中禁用自动缩进和代码补全