Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align texts in Sublime Text 3?

I use Sublime Text 3 Plug-in called AlignTab to align my code like this:

 Version : 1.4.1  Author  : Ken Wheeler  Website : http://kenwheeler.github.io  Docs    : http://kenwheeler.github.io/slick  Repo    : http://github.com/kenwheeler/slick  Issues  : http://github.com/kenwheeler/slick/issues 

Now, I want to my texts to stay next to the colon like this:

 Version: 1.4.1   Author: Ken Wheeler  Website: http://kenwheeler.github.io     Docs: http://kenwheeler.github.io/slick     Repo: http://github.com/kenwheeler/slick   Issues: http://github.com/kenwheeler/slick/issues 

How do I accomplish that ?

like image 781
code-8 Avatar asked Apr 10 '15 01:04

code-8


People also ask

How do I align in Sublime Text?

Using Sublime Alignment ↩ Simple: Select the lines you wish to align. Press Ctrl+Alt+A (Windows & Linux) or Command+Ctrl+A (Mac OS X)

How do I use beautify code in Sublime Text?

Beautify on Save sublime-settings : Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X.


1 Answers

You can do this with AlignTab, no need for a different plugin. You just need to use the more advanced regex functionality as described on the GitHub page.

Bring up the Command Palette (Ctrl+Shift+P on Windows or cmd+shift+P on Mac), type in "AlignTab", press enter, and type this in and hit enter:

:/r0clf1

Props to @Hank for including 0 spaces option, didn't even realize he didn't want the space.

Explanation:

  • the : finds the colon
  • the / says okay now here come some arguments about what I want you to do with the colon
  • the r means right-justify the first column
  • the 0 means 0 spaces after the right column
  • the c means center the middle column (which is just the colon, so it doesn't do anything)
  • the l means left-justify the right column
  • the f1 means only do this for the first match on the line
like image 198
Rob Wise Avatar answered Sep 21 '22 21:09

Rob Wise