是否可以突出显示一个大的注释块并在一定长度后自动插入中断?
简单的例子
# This is a super long message that has too much information in it. Although inline comments are cool, this sentence should not be this long.
Run Code Online (Sandbox Code Playgroud)
后
# This is a super long message that has too much information in it.
# Although inline comments are cool, this sentence should not be this
# long.
Run Code Online (Sandbox Code Playgroud)
ang*_*son 26
是! 它比这个答案的长度更简单!
有一个命令wrap_lines,它有能力达到你想要的.wrap_lines在Packages/Default/paragraph.py第112行中定义,并且在非官方文档的命令列表中稀疏地记录:
wrap_lines
包裹线条.默认情况下,它将行包裹在第一个标尺的列上.
- width [Int]:指定应包装行的列.
wrap_lines已经可以通过Edit -> Wrap菜单中的项目访问.有一些选项可以包含光标位于第70,78,80,100和120列的段落,以及第一个标尺.默认情况下,Wrap Paragraph at Ruler映射到Alt+QWindows和Super+Alt+QOSX上.
第一个统治者我的意思是什么?你可以召唤一个标尺View -> Ruler,但是如果你想要多个屏幕上(或者更愿意用你的标尺写),你可以添加一个整数的JSON数组 - 每个数组都定义一个标尺 - 任何.sublime-settings文件.例如,我添加到用户首选项文件中的数组如下所示:
"rulers":
[
79,
80,
72
],
Run Code Online (Sandbox Code Playgroud)
由于第一个标尺规则,Alt+Q将在79列标记处包裹一个超过79个字符的行,即使在第72列"它之前"有一个标尺."第一个标尺" 并不意味着最左边的标尺,而是首先定义标尺.如果我80,像下面那样移动到索引0,那么这些行将换行为80列.同样地72.
"rulers":
[
80,
79,
72
],
Run Code Online (Sandbox Code Playgroud)
你说,统治者是弱者吗?您还可以编写一个新的键绑定来在您选择的列中包装一行!只需在Preferences -> Key Bindings – User文件中添加以下内容即可:
{ "keys": ["alt+q"], "command": "wrap_lines", "args": {"width": 80} },
Run Code Online (Sandbox Code Playgroud)
删除args对象将改为包裹在第一个标尺上,就像Wrap Paragraph at Ruler命令一样.Wrap Paragraph at Ruler实际上是在默认的Windows keymap文件中定义的:
{ "keys": ["alt+q"], "command": "wrap_lines" },
Run Code Online (Sandbox Code Playgroud)
关于该wrap_lines命令的最好的(也是在某些情况下,最差的)事情之一是它将检测任何序列的非字母数字字符,这些字符开始该行并在换行时复制它.它非常适合编写注释,因为您的示例建议的行为确实发生了:
# This is a super long message that has too much information in it. Although inline comments are cool, this sentence should not be this long, because having to scroll to the right to finish reading a comment is really annoying!
Run Code Online (Sandbox Code Playgroud)
变为:
# This is a super long message that has too much information in it.
# Although inline comments are cool, this sentence should not be this
# long, because having to scroll to the right to finish reading a
# comment is really annoying!
Run Code Online (Sandbox Code Playgroud)
但是如果该行恰好以任何其他符号开头,比如引用的开头,那么Sublime Text也不知道如何包装它们.所以这:
# "This is a super long message that has too much information in it. Although inline comments are cool, this sentence should not be this long, because having to scroll to the right to finish reading a comment is really annoying!"
Run Code Online (Sandbox Code Playgroud)
成为这个,我们可能不想要:
# "This is a super long message that has too much information in it.
# "Although inline comments are cool, this sentence should not be this
# "long, because having to scroll to the right to finish reading a
# "comment is really annoying!"
Run Code Online (Sandbox Code Playgroud)
小心开始原始线路是个好主意.此外,该wrap_lines命令的目标是光标所触摸的整个段落,而不仅仅是当前行,也不仅仅是工作选择.这意味着您可以在新包装的一系列行上再次使用该命令将它们重新包装在不同的列中,但如果您正在对齐,您最终可能会包装一些您不想要的行. Markdown标题下的一个段落:
# Hey, this header isn't really there!
Be careful with what starts the original line. Also, the `wrap_lines` command **targets the entire paragraph**, not just the current line.
Run Code Online (Sandbox Code Playgroud)
如果在该文本块中的任何位置激活该命令,您将得到:
# Hey, this header isn't really there! Be careful with what starts the
original line. Also, the `wrap_lines` command **targets the entire
paragraph**, not just the current line.
Run Code Online (Sandbox Code Playgroud)
聪明地使用空格可以避免这种问题; 标题和段落之间的另一个空行将修复包装,因此:
# Hey, this header isn't really there!
Be careful with what starts the original line. Also, the `wrap_lines` command **targets the entire paragraph**, not just the current line.
Run Code Online (Sandbox Code Playgroud)
变为:
# Hey, this header isn't really there!
Be careful with what starts the original line. Also, the
`wrap_lines` command **targets the entire paragraph**, not just
the current line.
Run Code Online (Sandbox Code Playgroud)
由于操作速度非常快,因此您应该在追踪遇到的任何错误的原因,重新开始并创造性地避免它们时遇到太多麻烦.Sublime Text 在代码中混合注释和非注释通常没有任何问题,所以如果你很幸运,你将不必担心它!
| 归档时间: |
|
| 查看次数: |
5106 次 |
| 最近记录: |