Sublime Text
This is a set of tips and tricks for my own use, to help me survive Sublime. I’m using Sublime 3, as an attempt to transition from TextMate 2 that for some reason stopped working on my old (10.8.x) Mac.
Configuration tweaks
I’ve added the following configurations to “Preferences > Settings - User”:
// Note that the font_face and font_size are overridden in the platform
// specific settings file, for example, "Preferences (Linux).sublime-settings".
// Because of this, setting them here will have no effect: you must set them
// in your User File Preferences.
"font_face": "Consolas",
"font_size": 14,
// Set to true to removing trailing white space on save
"trim_trailing_white_space_on_save": true,
// Set to true to ensure the last line of the file ends in a newline
// character when saving
"ensure_newline_at_eof_on_save": true,
// Columns in which to display vertical rulers
"rulers": [80, 100],
// The number of spaces a tab is considered equal to
"tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
// Always visualise the viewport on the minimap, as opposed to only
// showing it on mouse over
"always_show_minimap_viewport": true,
// Draw a border around the visible part of the minimap
"draw_minimap_border": true,
// If enabled, will highlight any line with a caret
"highlight_line": true,
// Valid values are "smooth", "phase", "blink" and "solid".
"caret_style": "blink",
// These settings control the size of the caret
"caret_extra_width": 4,
// Set to true to automatically save files when switching to a different file
// or application
"save_on_focus_lost": true,
// When auto_find_in_selection is enabled, the "Find in Selection" flag
// will be enabled automatically when multiple lines of text are selected
"auto_find_in_selection": true,
// Makes tabs with modified files more visible
"highlight_modified_tabs": true,
// I wonder if setting this to true would help with Hugo detecting files
// properly...
// Setting to true is *not* recommended though...
// * https://github.com/SublimeTextIssues/Core/labels/C%3A%20Atomic%20Save
// * https://forum.sublimetext.com/t/st3-problem-with-encoding/10556/2
// * https://forum.sublimetext.com/t/why-is-atomic-save-useful/9291/12
// Save via writing to an alternate file, and then renaming it over the
// original file.
// "atomic_save": false,
// Theme support
"spacegray_sidebar_font_xlarge": true,
"theme": "Spacegray Eighties.sublime-theme",
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
I also added some user defined key bindings:
// Show current file in the sidebar: via http://julianhigman.com/blog/2013/07/23/sublime-text-3-keyboard-shortcut-to-reveal-file-in-sidebar/
{ "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"},
// Filter selection through external command
{ "keys": ["command+shift+\\"], "command": "filter_through_command" },
// Auto-format text selection
{ "keys": ["command+shift+t"], "command": "filter_through_command", "args": { "cmdline": "/Users/melo/.scripts.d/bin/x-text-autoformat" } },
// Perl Pretty Print
{ "keys": ["command+shift+h"], "command": "filter_through_command", "args": { "cmdline": "/Users/melo/.scripts.d/bin/x-perl-tidy-pipe" } },
// change single-quotes to double-quotes and vice-versa
{ "keys": ["command+shift+2"], "command": "change_quotes" }
Some require the External Command package, see below for Unix filters.
Markdown
I write a lot of Markdown. Install MarkdownEditing, it will help a lot.
I prefer a dark theme, so go to “Preferences > Settings - More > Syntax Specific - User” and add this setting:
"color_scheme": "Packages/MarkdownEditing/MarkdownEditor-Dark.tmTheme"
I also like to have spell checking activated so on the same file add:
"spell_check": true
An alternative to this package is Markdown Extended, but didn’t have the time to experiment, MarkdownEditing is good enough for me, and I found it first.
Unix filters
Support for calling an external command with the current selection or document is not something that ST includes out-of-the-box, strangely enough. Personally, I find this the most weird design decision of ST team, but I guess they prefer to push their Python-based plugin system. I rather prefer TextMate way of doing things here.
Not everything is lost though… The External Command package will give most of what is needed. The main issue that I have with it at this moment is that when the replacement text is inserted back into the page, the cursor location is lost.
Something like this, API: Set cursor position/view location?, but I don’t know enough of Python and ST plugin development to hack it in at the moment.
Other interesting packages
- Theme - SpaceGray: I use the “Eighties” version;
- SideBarEnhancements;
- ChangeQuotes: converts single-quoted strings to double-quoted strings and vice-versa;
- TrailingSpaces: magic with trailing space;
- BracketHighlight: strong visual queues about scopes, very useful for older people like me;
- AceJump: could not get it to work yet, but it looks promising.
More tips and tricks
- http://hugogiraudel.com/2015/05/18/writing-in-sublime-text/
- https://benfrain.com/top-tips-selection-unrelated-front-end-developer-tips/: learned about CTRL-minus in here, love this one…