Sublime Text is the most popular text / source code editor widely used in programming. Although it is a proprietary software, there are lots of free and community build plugins which can be used to extend the feature of Sublime Text. If you are not already fallen in love with Sublime Text, they you must give try.
Gist is a simple way to share snippets and pastes with others. This is one awesome service provided by GitHub. It allows you to store code snippets for later use, you can have as many private gists as you need and you can group multiple gist files under a single gist.
If you frequently use Gist then there is a Sublime Text plugin which helps you to use it easy way. You can manually install this Sublime Text plugin from this Gist github repository.Or you can install it through Package Manager.
Generate Access Token
You will need Access Token for using Gist in Sublime text.
- Open up GitHub site.
- Go to Account Settings -> Applications
- Click “Generate new token” under “Personal access tokens”
- Enter some meaningful name in “Token description”
- Under “Select scopes”, select gist
Setting up in Sublime Text
- Open Sublime Text
- Go to Preferences -> Package Settings -> Gist -> Settings – User
You will have to do some configuration before you can use it. In ‘token’, you will be to put access token you just generated. In ‘include_users’, put your github ID
Here is a sample settings.
{
"token": "s3924fdb1d93304f73fd1r13101e59f05b240d7f",
"include_users": ["ernilambar"]
}
Here are some options which you can configure. For details, you can check the default settings(Go to Preferences -> Package Settings -> Gist -> Settings – Default )
- token
- include_orgs
- include_users
- show_authors
- prefer_filename
- https_proxy
- use_starred
Using Gist in Sublime Text
You can find all functionality of the Gist plugin under Tools -> Gist menu and in the command palette.
Creating Gist
Use the Gist -> Create Public Gist or Gist -> Create Private Gist commands. If you don’t have anything selected, a Gist will be created with contents of current file, URL of that Gist will be copied to the clipboard and then the file will switch to Gist editing mode. If you have selected some text, a Gist will be created using only that text and then immediately opened for editing. In case of multiple selections, you’ll get one Gist with multiple files.
Editing Gist
Use the Gist -> Open Gist command to see a list of your Gists. Selecting one will open the files from that Gist in new tabs. You can then edit the files normally and save to update the Gist, or use other commands to change Gist description, remove or rename files, or delete the Gist.
Keyboard Shortcuts
Windows and Linux | OS X | |
Create Public Gist | Ctrl+K Ctrl+I | Super+K Super+I |
Create Private Gist | Ctrl+K Ctrl+P | Super+K Super+P |
Update File | Ctrl+K Ctrl+S | Super+K Super+S |
Open File | Ctrl+K Ctrl+O | Super+K Super+O |
Insert File | Ctrl+K Ctrl+[ | Super+K Super+[ |
Add File | Ctrl+K Ctrl+] | Super+K Super+] |