Sublime Forum

Custom Key Bindings -- syntax and conventions for sorting lines


For binding sort lines, case insensitive to the Windows+S key, this works:

{ “keys”: [“super+s”], “command”: “sort_lines”, “args”: {“case_sensitive”: false} }

Is it possible to include “unique” in that binding?

This doesn’t work:

{ “keys”: [“super+s”], “command”: “sort_lines”, “args”: {“case_sensitive”: false, “unique”: true} }

What might work, and where is the best documentation on this issue?




Save This @:

/Packages/___Your_Macro_Folder___/Sort Unique Lines.sublime-macro


		"command": "sort_lines",
		"args": { "case_sensitive": true },
		"command": "permute_lines",
		"args": { "operation": "unique" },


Add This @:

Preferences > Key Bindings - User


	"keys": [ "super+s" ],
	"command": "run_macro_file",
	"args":	{ "file": "res://Packages/___Your_Macro_Folder___/Sort Unique Lines.sublime-macro" },


More info @:

Sublime Text > Unofficial Documentation > Macros




Ok – combine a key binding with a macro. I’m surprised one can’t do this simply with a key binding with multiple arguments.

By the way, the current JSON conventions for defining key bindings (and other Sublime Text settings) could be radically simplified and a great deal of unnecessary and unsightly clutter removed. For instance:

keys; super+s; sort_lines; case_insensitive, unique

where the default structure and slots would be:

*format; *key; *command; *argument(s)

CSON and YAML are moving in this direction.

1 Like



Looks like there might be a round of user-suggested updates in the near future, you should post ( & vote ) @ the API Suggestions Thread  :wink:

1 Like


A general question: have you chosen Sublime Text after carefully comparing it to Atom, Emacs, Vim, Brackets, Notepad++ and other editors? I am just beginning to explore it and haven’t yet settled on it as my main text editor.

If so, what are the main features that sold you?

(I apologize if this isn’t an appropriate question for this forum.)



Expanding a bit on this proposal:

JSON-style key bindings:

{ "keys": ["ctrl+shift+n"], "command": "new_window" },
{ "keys": ["ctrl+shift+w"], "command": "close_window" },
{ "keys": ["ctrl+o"], "command": "prompt_open_file" },
{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" },
{ "keys": ["alt+o"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "hh", "h", "ipp", "inl", "m", "mm"]} },
{ "keys": ["ctrl+n"], "command": "new_file" },

Minimal-style key bindings (with most punctuation eliminated), where:

*format; *key; *command; *argument(s) // default slots separated by semicolons

keys; ctrl+shift+n; new_window
keys; ctrl+shift+w; close_window
keys: ctrl+o; prompt_open_file
keys; ctrl+shift+t; reopen_last_file
keys; alt+o; switch_file; extensions: cpp, cxx, cc, c, hpp, hxx, hh, h, ipp, inl, m, mm
keys; ctrl+n; new_file


IMO SublimeText is the best bet for now.  Vim & Emacs have powerful editing features but are dated in terms of UI ( & ST also has “Vintage” mode along with a few Vim extensions ). I used Notepad++ for a while before I found out about ST, but never really liked it ( UI is super clunky ).

To me, Atom & Light Table are the only editors in the same league as ST, but ST is way faster ( try working with 500+ selections in all three editors ). Light Table has the coolest features ( code watches, micro views, live rendering ), and Atom has the most extensible UI.

At the end of the day, I’m looking for performance & customization - and while Atom has strong UI customization, I feel that ST has a more powerful API with better performance behind it.  Python is also ideal for plugin development and it’s pretty easy to get ST to do whatever you need it to.  I’ve looked into the Electron & Atom APIs & they seem like kind of a hassle to use.



Great observations – I have come to similar conclusions in my initial investigations.

I might consider settling on Atom if its performance/speed were considerably improved. ST is much faster. Atom’s look and feel is a bit more modern to my taste than ST (for instance, it is more CSON-centric and YAML-centric).

Performance and customization is the name of the game – along with maximal minimalism for doing everything and a vibrant developer community.

1 Like