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

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

问题描述

您可以在 Netbeans 中创建80个字符/右边距线,文本配对和可能许多,许多其他IDE。是否有可能在Sublime Text 3中?任何选项,插件等。

解决方案

是的,这是可能的Sublime Text 2和3 > 真的 升级到,如果你还没有 - 不用担心 beta 名称,它的岩石坚固)。选择 视图→标尺→80 (还有其他几个选项)。如果您想要实际将文本换行为80列,请选择 视图→Word Wrap Column→80 。请确保已选择 视图→Word Wrap



(默认为打开的所有文件或视图),打开 首选项→设置 - 用户 ,然后使用以下任一项规则:

  {
//在指定列中设置垂直标尺。
//对于一个标尺使用rulers:[80]
//默认值为[]
rulers:[80,100,120],

//打开源和文本的换行符
//默认值为auto,表示关闭源和文本
word_wrap:true,

//在此列中设置字包装
//默认值为0,意味着包装发生在窗口宽度
wrap_width:80
}

这些设置也可以在 .sublime-project 文件中使用以设置默认值基于项目,或者在 syntax-specific .sublime-settings 文件if您只需要将它们应用于以某种语言编写的文件( Python.sublime-settings vs. JavaScript.sublime-settings )。通过打开所需语法的文件,然后选择 首选项→设置 - 更多→语法特定用户 ,访问这些设置文件。

一如往常,如果您的设置文件中有多个条目,请使用逗号分隔它们,除了最后一个之后。整个内容应括在花括号 {} 中。基本上,请确保它有效 JSON



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



最后,如另一个answer ,您真的应该使用等宽字体,以便您的代码正确排列。其他类型的字体具有可变宽度字母,这意味着一个80字符行可能不会显示为与另一个80字符行不同的内容相同的长度,你的压痕看起来都乱了。 Sublime有默认值设置的等宽字体,但您当然可以选择任何您想要的字体。就我个人而言,我真的很喜欢 Liberation Mono 。它有字形支持许多不同的语言和Unicode字符,看起来不错的各种不同的大小,(最重要的是一个编程字体)明确区分 0 O (数字零和大写字母oh)和 1 l (数字一和小写字母ell),不是所有的等宽字体做,不幸的是。版本2.0及更高版本的字体在开源 SIL Open字体许可1.1下授权(这里是常见问题)。


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

解决方案

Yes, it is possible both in Sublime Text 2 and 3 (which you should really upgrade to if you haven't already - don't worry about the "beta" name, it's rock-solid). 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.

To make your selections permanent (the default for all opened files or views), open Preferences → Settings—User and use any of the following rules:

{
    // 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
}

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—More → Syntax Specific—User.

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.

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.

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中的80个字符/右边距线3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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