A fork of SublimeERB, generalized to multiple templating systems
SublimeTemplater helps you insert template tags - Underscore's <% %>
, PHP's <? ?>
, or Angular's {{ }}
, and more - into your documents with one shortcut key. Inspired and forked from SublimeERB, repeated keypresses also allows you to cycle through a list of different template tags (<% %>
to <%= %>
). Template tags will also automatically surround selected text.
When SublimeTemplater is officially released it will be available on Sublime Package Control. It is not yet available there. Press ctrl
+shift
+p
on Windows/Linux and cmd
+shift
+p
on a Mac to bring up Sublime's Command Pallete, then type install package
to bring up Package Control's package selector. It should be the first selection. Type "SublimeERB," which, again, should be the first selection, and then hit enter.
Run the following commands:
git clone https://github.com/garetht/SublimeTemplater.git ~/.sublime_templater
ln -fs ~/.sublime_templater/ ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/SublimeTemplater
Run the following commands:
git clone https://github.com/garetht/SublimeTemplater.git ~/.sublime_templater
ln -fs ~/.sublime_templater/ ~/.config/sublime-text-2/Packages/SublimeTemplater
Download the repository from GitHub, and place it in a folder named SublimeTemplater.
From Sublime Text 2, go to the Preferences
menu, and from there select Browse Packages
. Copy the SublimeTemplater folder into that directory.
By default, that directory, the Sublime Text packages directory, is located at C:\Users\USERNAME\AppData\Roaming\Sublime Text 2\Packages
, where USERNAME
is the user name on your Windows machine.
- Clone the repository with
git clone https://github.com/garetht/SublimeTemplater.git
- Move the repository to the Packages directory of Sublime Text, or make a symbolic link to it.
By default, the shortcut to toggle templates is bound to ctrl
+shift
+.
, but you can change this in your user settings.
Sublime Text 3 support is not available at this time.
While SublimeTemplater makes some crude attempts to determine which tags it should apply given the syntax of the file you are working on, you can also set the template syntax manually by pressing cmd
+shift
+p
to bring up the command palette, and then typing in sublimetemplater
(or something shorter that brings the SublimeTemplater options up), and choosing the syntax you wish.
By default, SublimeTemplater binds the tag insert and cycle command to ctrl
+shift
+.
. You can also place this in your user keybinding preferences (Sublime Text 2 > Preferences > Key Bindings - User
on Mac, Preferences > Key Bindings - User
on Windows)
[
{ "keys": ["ctrl+shift+."], "command": "templater" }
]
You can also modify your user keybindings file to enable the shortcut in the most common templating contexts:
[
{ "keys": ["ctrl+shift+."], "command": "templater", "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html.ruby, text.haml, source.yaml, source.css, source.scss, source.js, source.coffee" }
]
}
]
Now you can use ctrl+shift+.
to create and toggle between templates of a certain syntax.
If you followed the quick manual install instructions, you can use these commands to update your installation of SublimeTemplater.
cd ~/.sublime_templater
git pull --rebase
SublimeTemplater is copyrighted 2013 by Gareth Tan, and is released under the MIT License.
SublimeERB is Copyright (c) 2011 Carlos Rodriguez, released under the MIT License.