你可以在Netbeans, Text Mate和其他很多ide中设置80个字符/右边距。有可能在Sublime Text 3中也有吗?任何选项,插件等?


当前回答

是的,在Sublime Text 2, ST3和ST4中是可能的(如果你还没有升级到它,你真的应该升级到它)。选择视图→标尺→80(还有其他几个选项)。如果你想把文本换行到80列,选择“查看→换行列→80”。确保选择了“查看→自动换行”。

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

{
    // 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文件中以每个项目为基础设置默认值,或者如果你只希望它们应用于以某种语言(Python)编写的文件,也可以用在语法特定的.sublime-settings文件中。sublime-settings vs. JavaScript。例如,崇高的设定)。通过打开具有所需语法的文件来访问这些设置文件,然后选择首选项→设置-特定语法。

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

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

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).

其他回答

要做到这一点,你的字体也需要设置为monospace。 如果你仔细想想,线条不可能完美地排列起来。

答案详见sublime文本论坛: http://www.sublimetext.com/forum/viewtopic.php?f=3&p=42052 这个答案有链接,教你如何为你的操作系统选择合适的字体, 并给出字体不对齐的边缘情况的答案。

另一个网站为程序员列出了很棒的等宽字体。 http://hivelogic.com/articles/top-10-programming-fonts

在stackoverflow中,请参见:

Michael Ruth的回答是: 如何使标尺始终显示在崇高的文本2?

MattDMo的答案是: Sublime Text的默认字体是什么?

我有标尺设置如下: 30. 50 (git提交消息标题应该限制在50个字符) 72 (git提交消息细节应该限制在72个字符) 80 (Windows命令控制台窗口的最大宽度为80个字符)

其他受益于较短队列的观看环境: Github:在线查看文件时没有自动换行 所以,我尽量保持.js .md和其他文件在70-80个字符。 Windows控制台:80个字符。

是的,在Sublime Text 2, ST3和ST4中是可能的(如果你还没有升级到它,你真的应该升级到它)。选择视图→标尺→80(还有其他几个选项)。如果你想把文本换行到80列,选择“查看→换行列→80”。确保选择了“查看→自动换行”。

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

{
    // 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文件中以每个项目为基础设置默认值,或者如果你只希望它们应用于以某种语言(Python)编写的文件,也可以用在语法特定的.sublime-settings文件中。sublime-settings vs. JavaScript。例如,崇高的设定)。通过打开具有所需语法的文件来访问这些设置文件,然后选择首选项→设置-特定语法。

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

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

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).