Friday, 4 December 2015

How To Use Sublime Text For Live Preview

Sublime _ A Notepad Like Software

Hello Readers My Name is Arslan Ahmed Awan. Today I am Going to tell you about How To Use 

Sublime Text For Live Preview.


A web developer may bang improved near what gasify text is actually able of. So no necessity to treat it here. The one things I kept intelligent for in Sublimate Book or in any connatural sandy unit schedule was the knowledge to guide the termination as soon as you type. But works unable to gestate it, so the exclusive option socialist was to use online tools like JsFiddle or JsBin. But what if we are offline? We human to type the write in our HTML or some line, refrain it, switching to browser, regenerate the attender to get the results. Whatever change.

But what if we can miss or should I say AUTOMATE the action and refreshing voice. Sounds good? So quit wasting the abstraction and see the nation of Aerify Schoolbook.

Alright! Lets Begin.

Step 1 :  Run Sublime Text.

Step 2 :  Create a new file and paste this code in it.
import sublime_plugin

class SaveOnModifiedListener(sublime_plugin.EventListener):
    def on_modified(self, view):
        view.run_command("save")
Step 3 : Save it as a .py (python) file. For example Autosave.py
What it actually do is, it saves the file after every keystroke. So whatever you type will be saved immediately.

Step 4 : Move this newly created file to, user folder in sublime text directory. For example,
C:\Program Files\Sublime Text\Data\Packages\User
Installation directory and folder doesn't matter, it could be anywhere. The main things is to place this .py file in the user folder.

Step 5 :  Almost done. Create 3 new files in Sublime Text. One for html, one for css and one for javascript. You can skip this part but it will give a fancy look to our editor and we can place our relevant code to get immediate results.

Step 6 :  Link your css and javascript to your html file. You know how :)

Step 7 : Now to the last magic trick. In your html file, add this line to the top.
<meta http-equiv="refresh" content="0.5">

Step 8 : This will refresh the page after every half (0.5) second. You will barely notice it. So no need to refresh the page in our browser. If you are working on transition and animations then change it to 3 seconds or so.

Step 9 : In Sublime Text you adjust the number of rows or columns if you like. You will find it under view menu. Here is what you can achieve with this.


Now you have the power of Sublime Text and the Live Preview, well! Almost Live Preview.


If you find any error in doing it , then let me know by Commenting under this post.

www.MuzamilTricks.com

Share:

0 comments:

Post a Comment