Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7654865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:21:58+00:00 2026-05-31T12:21:58+00:00

I would like to create a Sublime Text 2 Snippet that fills up the

  • 0

I would like to create a Sublime Text 2 Snippet that fills up the space before and after the Variable I type with spaces.

It should look like this:

===========================my_filename.js===========================

The Filename should be centered so the number of spaces before and after the Text have to match.
Also I need the overall column width of this line the stay the same. So when I add 2 Characters the number of spaces on each side gets reduced by one.

I think a sample for this would be:

spacesLeft  = roundDown((columnWidth/2) - (textSize/2))
spacesRight = roundUp((columnWidth/2) - (textSize/2))

But since only RegEx is available in Sublime Snippets I don’t see me able, to accomplish this task.

Could Vintagmode help me in any Way?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:21:59+00:00Added an answer on May 31, 2026 at 12:21 pm

    Because snippets are essentially static, they wouldn’t be able to help you in this case. However, you could create a plugin to do this relatively easily. Sublime Text uses python for its plugins. You can create one by going to Tools > New Plugin. ST2’s API can be found here and is very impressive. Essentially, you’ll want to store the current selection (your variable) using

    sel_reg = self.view.sel()[0] # the current selection 'Region'
    sel = self.view.substr(sel_reg) # the text within the 'Region'
    

    Then generate the =’s

    signs = ''
    each_side = len(80 - len(sel))/2 # 80 is the standard window length, 
                                       # change this to what you want.
                                       # Not sure about how to make it dynamic.
    for x in xrange(each_side):
      signs += '='
    

    Then replace the current line (self.view.line(sel)) with signs + sel + signs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a function that keeps a record of every print
I would like to create some logic with in my Rails app that is
I would like create URL rewrite rule that will set default document for my
I would like create a custom DataRow that will have -let's say- a propery
I would like create a database using value from a variable. Here my script
I would like create a GLOBAL VARIABLE in a Sql script. For my understanding
I would like create an inner shadow on my UIView on iPad like that
would like to create a function that generates graphs using ggplot. For the sake
I would like to create a function that returns a numpy array if one
I would like to create an XML file like this: <?xml version=1.0 encoding=UTF-8?> <text>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.