Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户尝试在代码镜像中的文档的第 80 列之后键入任何字符时,我是否可以强制换行。
也可选择用于下一行的缩进
是的,有办法做到这一点。在光标活动时,测试当前字符索引是否为 80 或更大。如果是这样,请将选择替换为新行 "\n" 。但你真的想这样做吗?把一个词分成两半?
editor.on("cursorActivity" ,function(editor){ currentChar = editor.getCursor().ch if (currentChar >= 80){ editor.replaceSelection("\n" ,"end") } })