Categories: Tools

How Sublime Editor Can be Used For Blogging – Part 1

This article represents tips on how one could use Sublime Text Editor for writing their blogs in quicker manner. More so, if you are a developer and love blogging, you would find Sublime handy as you could write blog like coding by creating custom snippets as described later in the article. 🙂 The reason I have put this article as “Part 1” is because I believe I shall come across more such tips & techniques as I go ahead with my experience with Sublime and, I shall share them as another blogs. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
I also came across one similar article on How Sublime can be used as a blogging tool, that you may want to check.

 

Following are the key points described later in this article:

  • Common Use-case Scenarios for Blogging
  • Tips to Configure Sublime as a Blogging Editor

 

Common Use-case Scenarios for Blogging

Listed below are common use-case scenarios where in Sublime could prove to be very useful.

  • Custom Blog Templates: Our blogs falling in different categories tends to follow a specific set of custom text and styles including a combination of heading, ordered/unordered list, divs etc. This is where one could one or more Sublime snippets where each snippet can represent a particular blog template. For example, following could be one snippet for a blog template. With below snippet, you create a new empty HTML file in sublime and write “blogtemp” & CTRL + “space bar” and the code below appears. You could start writing your blog right away based on this template.
    <snippet>
     <content><![CDATA[
    <div>This article describes $1.</div>
    &nbsp;
    <div>
     Following are the key points discussed later in this article:
     <ul>
      <li>$2</li>
      <li>$3</li>
     </ul>
    </div>
    &nbsp;
    <div>
     <h6>$4</h6>
    </div>
    ]]></content>
     <tabTrigger>blogtemplate1</tabTrigger>
     <scope>text.html</scope>
    </snippet>
  • Ordered/Unordered Lists: Several times while blogging one needs to list down one or more points. This is where one need to create ordered/unordered lists using ul/ol and li tags. Take a look at sample sublime code snippet below:
    <snippet>
     <content><![CDATA[
    <ul>
     <li>$1</li>
     <li>$2</li>
    </ul>
    ]]></content>
     <tabTrigger>blogul</tabTrigger>
     <scope>text.html</scope>
    </snippet>
  • Custom Style – Heading with Spacing/Padding: At times, we use custom styles for putting headings in the blog along with custom spacing/padding.
  • Code blocks: At times, based on plugin one use for putting the source code, one needs to write code appropriately (with pre & code element).

 

Tips to Configure Sublime as a Blogging Editor

You could create a Sublime custom snippet based on following instructions:

  • In Sublime Text Editor, go to Tools > New Snippet. A new untitled file consisting of following code would open. Paste one of the code snippet shown above in the article.
    <snippet>
     <content><![CDATA[
        Hello, ${1:this} is a ${2:snippet}.
        ]]></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <!-- <tabTrigger>hello</tabTrigger> -->
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <!-- <scope>source.python</scope> -->
    </snippet>
  • Give an appropriate name within “TabTrigger” element. This would be name you would write in the editor followed by ctrl + “space bar” to autocomplete. I put the name such as “blogtemplate1”. The code would look like following:
    <tabTrigger>blogtemplate1</tabTrigger>
  • Write the source type as “text.html” within scope element. The code would like following:
    <scope>text.html</scope>
  • Once done with above steps, its time to save the file. The file name must end with .sublime-snippet. You could choose format such as filetype-triggername.sublime-snippet. For above, I used filename such as html-blogtemplate1.sublime-snippet
  • Close and re-open the sublime. Test by writing “blogtemp” and ctrl + “space bar” to see autocomplete option. You shall find your snippet displayed for selection.

[adsenseyu1]

Nidhi Rai

Nidhi has been been actively blogging in different technologies such as AI / machine learning and internet technologies. Her field of interest includes AI / ML, Java, mobile technologies, UI programming such as HTML, CSS, Javascript (Angular/ReactJS etc), open-source and other related technologies.

Recent Posts

Agentic Reasoning Design Patterns in AI: Examples

In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…

1 month ago

LLMs for Adaptive Learning & Personalized Education

Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…

2 months ago

Sparse Mixture of Experts (MoE) Models: Examples

With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…

2 months ago

Anxiety Disorder Detection & Machine Learning Techniques

Anxiety is a common mental health condition that affects millions of people around the world.…

2 months ago

Confounder Features & Machine Learning Models: Examples

In machine learning, confounder features or variables can significantly affect the accuracy and validity of…

2 months ago

Credit Card Fraud Detection & Machine Learning

Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…

2 months ago