Open
Description
In a situation like
a & b & c
aaa & bbb & ccc
one would like to be able to select all the &
, press ctrl+alt+a
and obtain
a & b & c
aaa & bbb & ccc
but currently the plugin only aligns the first ones (with too many spaces):
a & b & c
aaa & bbb & ccc
My suggestion is to change the code handling multiple selections as follows:
# This handles aligning multiple selections
else:
col = {}
curline = view.rowcol(sel[0].begin())[0]
j=0
for i in range(0,len(sel)):
ln = view.rowcol(sel[i].begin())[0]
if ln != curline:
j=0
curline = ln
if j in col.keys():
col[j].append(i)
else:
col[j] = [i]
j+=1
for j in col.keys():
max_col = max([normed_rowcol(view, sel[i].b)[1] for i in col[j]])
for i in col[j]:
region = sel[i]
length = max_col - normed_rowcol(view, region.b)[1]
view.insert(edit, region.b, ' ' * length)
if settings.get('mid_line_tabs') and not use_spaces:
convert_to_mid_line_tabs(view, edit, tab_size, region.b, length)
which groups the selections by rows and processes the first sel of each row, then the seconds etc.
This is particularly useful when writing LaTeX tables for example.
Metadata
Assignees
Labels
No labels