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.?
相关问题
- How to run code in Sublime text 2 python
- Python Parameterize Formatting
- How do you configure MinGW with Sublime Text 3?
- Easier way to prevent numbers from showing in expo
- Using @string resource inside a style definition
相关文章
- Python relative import with more than two dots
- Bind a char to an enum type
- In OOP, what is the best practice in regards to us
- Quoting YAML (for Travis CI)
- Formatting a double in JSF
- Why do some users quote classnames in Perl?
- If 'else' is about to happen anyway should
- .NET GUID uppercase string format
For this to work, your font also needs to be set to monospace.
If you think about it, lines can't otherwise line up perfectly perfectly.
This answer is detailed at sublime text forum:
http://www.sublimetext.com/forum/viewtopic.php?f=3&p=42052
This answer has links for choosing an appropriate font for your OS,
and gives an answer to an edge case of fonts not lining up.
Another website that lists great monospaced free fonts for programmers. http://hivelogic.com/articles/top-10-programming-fonts
On stackoverflow, see:
Michael Ruth's answer here: How to make ruler always be shown in Sublime text 2?
MattDMo's answer here: What is the default font of Sublime Text?
I have rulers set at the following:
30
50 (git commit message titles should be limited to 50 characters)
72 (git commit message details should be limited to 72 characters)
80 (Windows Command Console Window maxes out at 80 character width)
Other viewing environments that benefit from shorter lines: github: there is no word wrap when viewing a file online
So, I try to keep .js .md and other files at 70-80 characters.
Windows Console: 80 characters.
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, selectView → Word Wrap Column → 80
. Make sure thatView → 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: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 selectingPreferences → 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
andO
(digit zero and capital letter oh) and1
andl
(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).