Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quickly setup Sublime Text 3 for Angular 2

Quick Setup for Sublime Text 3 for Angular 2

Easy to remember, easy to forget.

Step 1: Download Sublime Text 3

Sublime Text 3 Download

Step 2: Create a bash shortcut

It's nice to be able to run subl in a terminal.

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Step 3: Install Package Manager

Hit Ctrl+` to open the terminal and execute the python code below:

import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

Step 4: Add the Typescript Package

  • Cmd+P
  • Install Package
  • TypeScript
  • Restart

Step 5: Configure TypeScript tabs

  • Preferences > Settings > Syntax Specific (User)
{
  "tab_size": 2,
  "translate_tabs_to_spaces": true
}
@themathmagician

This comment has been minimized.

Copy link

commented Nov 1, 2016

step 4 should be: cmd+shift+P

@datgrog

This comment has been minimized.

Copy link

commented Nov 19, 2016

step 4 should be: cmd+shift+P

👍

@zaherab

This comment has been minimized.

Copy link

commented Jan 10, 2017

I'm getting an error in step 3:
-bash: syntax error near unexpected token `('
any idea how to solve it??
Thank you

@miikkaa

This comment has been minimized.

Copy link

commented Jan 16, 2017

Step 3 doesn't work either, might be targeting an old release. Use a snippet from https://packagecontrol.io/installation, which is updated regularly.

@archenroot

This comment has been minimized.

Copy link

commented Mar 21, 2017

Thanks a lot for this guys!
By coincidence I found non-blocking bug in KDE plasma 5.8 while clicking on Sublime menu - https://bugs.kde.org/show_bug.cgi?id=377880

@Giangnv2014

This comment has been minimized.

Copy link

commented Mar 25, 2017

👍

@olaoluwa-98

This comment has been minimized.

Copy link

commented Apr 6, 2017

Is there an actual Angular plugin for sublime. Not javascript or typescript but the one that recognizes the syntax for Angular

@RajeshCh17

This comment has been minimized.

Copy link

commented May 17, 2017

Just search it after pressing Ctrl + shift + P,it will come if you have not installed in it your editor.

@thisistheaj

This comment has been minimized.

Copy link

commented May 22, 2017

This fails to accomplish 2 things:

  1. does not address html files in angular projects (or even template strings): i.e. does not complete thing such as *ngFor="", *ngIf="", [(ngModel)]="", (click)="" etc.

  2. Does not address components and events created by the user (or another framework like Ionic): i.e. does not complete things such as <my-component></my-component> created by the user, or <button ion-button></button> created by Ionic Framework 2/3 etc.

@RajeshCh17: that is doable, but unfortunately it is hard to separate Angular plugins from Angularjs plugins (which there are more of). It is not helpful to developers looking to confirm online: "What is the de-facto standard Angular 2/4 plugin for sublime 3?"

@michalmw

This comment has been minimized.

Copy link

commented Sep 14, 2017

Hey, what about autoimport?

when i in component write:

constructor(private router: Route.. <then click enter and in inport part of my file (top) start import { Router } form '@angular....' ? Any idea? - I can pay for this plugin..

@shazmoh

This comment has been minimized.

Copy link

commented Oct 1, 2017

Step 3 didn't work. Snippet from https://packagecontrol.io/installation worked as mentioned by @miikkaa

@saulcstartx

This comment has been minimized.

Copy link

commented Nov 7, 2017

Step 3 is in the sublime terminal, I mean, Open subl and then use Ctrl + `. I got an error related to the h = '...88', I just change it with the suggested value in the error and it works! I hope that can help you! ;)

@navrudh

This comment has been minimized.

Copy link

commented Dec 11, 2017

step 5. b. could be to install the EditorConfig plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.