Sublime Text is great, but a few settings should be enabled as default to make the experience even better. Open your user setting file by pressing command + , on Mac or ctrl + , on windows. Or go to Preferences -> Settings - User:
TL;DR: just copy and paste the following chunk into your user setting file:
"always_show_minimap_viewport": true,
"indent_guide_options": [ "draw_normal", "draw_active" ],
"line_padding_bottom": 3,
"line_padding_top": 3,
"highlight_modified_tabs": true,
"scroll_past_end": true,
"translate_tabs_to_spaces": true,
"find_selected_text": true,
"word_wrap": true,
"ensure_newline_at_eof_on_save": true,
"bold_folder_labels": true,
and the following to Preferences -> Key Bindings - User:
{ "keys": ["command+v"], "command": "paste_and_indent",},
{ "keys": ["command+shift+v"], "command": "paste",},
Got 5 mintues to read?
Show current location on minimap
By default, the minimap does not highlight your current location. Use this setting to turn it on:
"always_show_minimap_viewport": true,
Convert tabs to spaces
It is import to convert tabs to white spaces when coding in Python, Ruby, YAML etc. To do that:
"translate_tabs_to_spaces": true,
Indentation by 4 spaces or 2 spaces depend on the language, it is better off to set the tab_size property separately for different file types. For instance, if I code in Python, I want the tab size to be 4 spaces. If I code in Ruby, I want it to be 2. To do this,
- Open a new document and click the bottom right corner (which says Plain Text) and set the language type to Python for instance
- Go to Preferences -> Settings - More -> Syntax Specific - User
- A file named ** Python.sublime-settings ** should be opened
Add the following lines:
{
"tab_size": 4,
}
Enable word wrap
"word_wrap": true,
Find highlighted text
When you have a phrase highlighted and press command + f to look it up in the document, the highlighted word is not automatically copy and pasted to the Find dialog box. This can be fixed by:
"find_selected_text": true,
Scroll past the end of the document
It is sometimes awkward to look at lines at the bottom of the screen. You can actually scroll the windows pass the last line of the document:
"scroll_past_end": true,
Highlight indentation level
When writing in a language that requires multiple levels of indentations (like Python), highlighting the current indentation the cursor is in makes finding yourself within the nested code structure easier:
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
You can find a screenshot of this on Wes Bos' blog.
Adjust line height to increase readability
The default line height is too narrow for the eyes. Change it to a number that looks more comfortable:
"line_padding_bottom": 3, // adjust the number as you like
"line_padding_top": 3,
Highlight tabs with unsaved changes
"highlight_modified_tabs": true,
Ensure newline at end of file on save
UNIX/Linux convention is to have a newline at the end of the file. When collaboration with people using different OS, this is important:
"ensure_newline_at_eof_on_save": true,
WARNING:
You may attempt to set this as well:
"trim_trailing_white_space_on_save": true
But this can be hazardous if you write in Markdown. Because two trailing white spaces in Markdown means a newline character. A workaround proposed by this blog is to set the setting to True in the user setting file and set it to false in the Mardown syntax file.
Make folder name bold in the sidebar
"bold_folder_labels": true,
Paste code without having to fix indentation
This is definitely an annoying issue that everybody encounters all the time. When you copy and paste a block of indented code, the indentation on certain lines of the copied code is guaranteed to be messed up.
Sublime Text acutally has an Paste and Indent option which fix this issue but it is bind to command+shift+v instead of command+v. To fix this, Open Preferences -> Key Bindings - User and paste the following lines:
{ "keys": ["command+v"], "command": "paste_and_indent",},
{ "keys": ["command+shift+v"], "command": "paste",},
References:
http://stackoverflow.com/questions/25900954/80-characters-right-margin-line-in-sublime-text-3
https://www.sublimetext.com/forum/viewtopic.php?f=2&t=2478
http://wesbos.com/sublime-text-5-visual-tweaks/
http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/settings.html