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.?
80-characters / right margin line in Sublime Text 3
coding-styleformattingsublimetextsublimetext3sublimetext4
Best Answer
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, 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
and use any of the following rules in the right-side pane: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—Syntax Specific
.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).