Add a semicolon at line end with Sublime Text

Two step process but oh so worth it 🙂

First create a file in your User directory (on Ubuntu it’s /home/username/.config/sublime-text-3/Packages/User/, I believe) and name it Line terminator and newline.sublime-macro. Open the file and put in the following:

{ "command": "move_to", "args": {"to": "eol"} },
    { "command": "insert_snippet", "args": {"contents": "${TM_LINE_TERMINATOR:;}"} }

Then open your key map file (Under Preferences > Key Bindings – User and put in

{
    "keys": ["alt+super+enter"],
    "command": "run_macro_file",
    "args": {"file": "Packages/User/Line terminator and newline.sublime-macro"}
}

(You can of course update the keys used to whatever works for you).

Then use it as you would with any key binding – it will automatically insert the semicolon at the end of the current line for you! 🙂

Source: http://sublimetext.userecho.com/topic/90524-add-semicolon-and-newline/

Advertisements