Sublime Forum

Help Requested: Modify VAlign

#1

I spoke with the author of the VAlign plugin, and he currently isn’t updating the plugin. It works great in ST3 which is why I like it and it is much more intelligent than “Alignment” as you don’t need to select text and it will auto align. But it does not handle new lines and I don’t know Python to modify it to allow that.

I’d like to be able to align this automatically without grouping them together then splitting them apart again after:

local a = ‘a’
local a2 = ‘a’

local b = ‘b’
local bb = ‘bb’

Right now, it will align either one, if you select one then do the second one, it aligns both but not relative to each other.

0 Likes

#2

try this, it will do the job.
github.com/randy3k/AlignTab

There are two ways to do this

  1. select the piece of code you want to align, or
  2. put a cursor in one of the lines in each block of code
    then apply the alignment.

It detects the alignment blocks and handles the alignment globally.

0 Likes

#3

[quote=“randy3k”]try this, it will do the job.
github.com/randy3k/AlignTab

There are two ways to do this

  1. select the piece of code you want to align, or
  2. put a cursor in one of the lines in each block of code
    then apply the alignment.

It detects the alignment blocks and handles the alignment globally.[/quote]

Don’t you have to create Regex for each alignment you want per syntax.

0 Likes

#4

If you want to define a keybind just to align “=”, put the following into your user keybind file (change the key if you want)

//align = { "keys": "super+shift+a"], "command": "align_tab", "args" : {"user_input" : "=/f"} }
This keybind works for all syntaxes.

If you want to define syntax specific keybind, then consider the following

  //align = for python
  {
    "keys": "super+shift+a"], "command": "align_tab",
    "args" : {"user_input" : "=/f"},
    "context":    { "key": "selector", "operator": "equal", "operand": "source.python" } ]
  }
0 Likes