texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.69k stars 344 forks source link

More environments for auto-alignment of table cells #2285

Open flenzen opened 2 years ago

flenzen commented 2 years ago

There is the auto-alignment feature for tabular content (in German, called "richte Spalten aneinander aus"; could anyone add the English name of the menu entry, please?). I would appreciate of this feature supported

a) more environments, b) other alignment characters.

At best, the user could just add further alignment characters and table environments in the settings.

Describe the feature and the current behavior/state

The auto-alignment feature seems to work only for specific table-like environments (tabular, array, matrix), but not all (e.g., blockarray). It seems to only align w.r.t. ampersand signs, but not, e.g., in a tikz-cd environment, for which ampersand replacement=\& has been used.

Who will benefit with this feature?

Anyone who uses tikz-cd, as using ampersand replacement is often needed. Users of blockarray, nicematrix etc.

sunderme commented 2 years ago

the second part should work now (dev. version, coming 4.3.0)

flenzen commented 1 year ago

What do you mean by the second part? Further alignment characters as in b) has not become a feature yet, has it?

benibela commented 1 year ago

you can also always alt+ctrl+click on each aligment character, and then use edit / line operations / align cursors

flenzen commented 1 year ago

Ah. That I did not know. That's a good help for now. But a bit tedious, to be honest. It would be more usable if I could get a bunch of cursors for all the matches of a search for \&.

benibela commented 1 year ago

It would be more usable if I could get a bunch of cursors for all the matches of a search for \&.

Then you search (in selection), and go on Edit / searching / Select all matches

And press left arrow to clear the selection before using align cursors

flenzen commented 1 year ago

Okay. To be honest, I did not know about these too. I came up with a macro

%SCRIPT
editor.find("\\&", false, false, false, false, false, true);
editor.selectAllMatches();
app.simulateKeyPress("Left");
app.simulateKeyPress("Left");

that, combined with a shortcut for Select all matches, does the job for me. But this has certain shortcomings, compared to the native Align columns feature. I assume these can be addressed within the realm of scripts, but for me, everything beyond what's in the manual about scripts is quite opaque.