启用换行后如何在 Ace Editor 中禁用后续行的缩进
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>
如您所见,太长的行正确换行到下一行,但由于某种原因,换行部分前面有一些奇怪的缩进。我怎样才能摆脱它?
在调用 setUseWrapMode
之前,您需要在 session
上将选项 indentedSoftWrap
设置为 false
。请参阅下面的工作示例:
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] (which - in my opinion - would make more sense), but it was changed[2],然后才登陆插件的代码库。
我有以下代码:
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>
如您所见,太长的行正确换行到下一行,但由于某种原因,换行部分前面有一些奇怪的缩进。我怎样才能摆脱它?
在调用 setUseWrapMode
之前,您需要在 session
上将选项 indentedSoftWrap
设置为 false
。请参阅下面的工作示例:
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] (which - in my opinion - would make more sense), but it was changed[2],然后才登陆插件的代码库。