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
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: