Sublime Text 3 中的 80 个字符/右边距线 [英] 80-characters / right margin line in Sublime Text 3

查看:11
本文介绍了Sublime Text 3 中的 80 个字符/右边距线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 NetbeansText Mate 可能还有很多很多其他 IDE.是否也可以在 Sublime Text 3 中使用它?任何选项,插件等?

You can have 80-characters / right margin line in Netbeans, Text Mate and probably many, many more other IDEs. Is it possible to have it in Sublime Text 3 as well? Any option, plugin etc.?

推荐答案

是的,在 Sublime Text 2、ST3 和 ST4 中是可能的(你应该真的 升级到如果你还没有).选择 View → Ruler → 80(那里还有其他几个选项).如果您希望将文本实际换行为 80 列,请选择 View → Word Wrap Column → 80.确保选择了 View → Word Wrap.

Yes, it is possible in Sublime Text 2, ST3, and ST4 (which you should really upgrade to if you haven't already). Select View → Ruler → 80 (there are several other options there as well). If you like to actually wrap your text at 80 columns, select View → Word Wrap Column → 80. Make sure that View → Word Wrap is selected.

要使您的选择永久化(所有打开的文件或视图的默认设置),请打开 Preferences → Settings 并使用以下任意选项右侧窗格中的规则:

To make your selections permanent (the default for all opened files or views), open Preferences → Settings and use any of the following rules in the right-side pane:

{
    // set vertical rulers in specified columns.
    // Use "rulers": [80] for just one ruler
    // default value is []
    "rulers": [80, 100, 120],

    // turn on word wrap for source and text
    // default value is "auto", which means off for source and on for text
    "word_wrap": true,

    // set word wrapping at this column
    // default value is 0, meaning wrapping occurs at window width
    "wrap_width": 80
}

这些设置也可以在 .sublime-project 文件中使用,以在每个 project 基础,或在 syntax-specific .sublime-settings 文件,如果你只希望它们应用于以某种语言编写的文件(Python.sublime-settingsJavaScript.sublime-settings,例如).通过打开具有所需语法的文件,然后选择 Preferences → Settings—Syntax Specific 来访问这些设置文件.

These settings can also be used in a .sublime-project file to set defaults on a per-project basis, or in a syntax-specific .sublime-settings file if you only want them to apply to files written in a certain language (Python.sublime-settings vs. JavaScript.sublime-settings, for example). Access these settings files by opening a file with the desired syntax, then selecting Preferences → Settings—Syntax Specific.

与往常一样,如果您的设置文件中有多个条目,请用逗号分隔它们,, 除了最后一个之后.整个内容应该用大括号 { } 括起来.基本上,确保它是有效的 JSON.

As always, if you have multiple entries in your settings file, separate them with commas , except for after the last one. The entire content should be enclosed in curly braces { }. Basically, make sure it's valid JSON.

如果您想要一个组合键自动将特定视图/文件的标尺设置为 80,或者您有兴趣了解如何在不使用鼠标的情况下设置值,请参阅 我的答案在这里.

If you'd like a key combo to automatically set the ruler at 80 for a particular view/file, or you are interested in learning how to set the value without using the mouse, please see my answer here.

最后,正如 another answer 中所述,您真的应该使用等宽字体为了让您的代码正确排列.其他类型的字体具有可变宽度字母,这意味着一个 80 个字符的行可能看起来与另一个具有不同内容的 80 个字符的行的长度不同,并且您的缩进看起来会一团糟.Sublime 有等宽字体默认设置,但您当然可以选择任何您想要的字体.就个人而言,我真的很喜欢 Liberation Mono.它具有支持许多不同语言和 Unicode 字符的字形,在各种不同的大小上看起来都很好,并且(最重要的是对于编程字体)清楚地区分 0O(数字零和大写字母 oh)和 1l(数字 1 和小写字母 ell),不幸的是,并非所有等宽字体都这样做.2.0 及更高版本的字体在开源 SIL Open Font 下获得许可许可证 1.1(这里是 FAQ).

Finally, as mentioned in another answer, you really should be using a monospace font in order for your code to line up correctly. Other types of fonts have variable-width letters, which means one 80-character line may not appear to be the same length as another 80-character line with different content, and your indentations will look all messed up. Sublime has monospace fonts set by default, but you can of course choose any one you want. Personally, I really like Liberation Mono. It has glyphs to support many different languages and Unicode characters, looks good at a variety of different sizes, and (most importantly for a programming font) clearly differentiates between 0 and O (digit zero and capital letter oh) and 1 and l (digit one and lowercase letter ell), which not all monospace fonts do, unfortunately. Version 2.0 and later of the font are licensed under the open-source SIL Open Font License 1.1 (here is the FAQ).

这篇关于Sublime Text 3 中的 80 个字符/右边距线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆