I had a similar problem and wrote a short macro to help me.
You select the separator and the new column marker and it calculates the correct width for each column.
Maybe you can customize it to your need. ( Just do a Google Translate for the Norwegian comments.. )
/**
* Prosedyre: typeless MAS_Format_Column()
*
* @key Alt + B + F
*
* @author Morten (2012-06-26)
*
* @return typeless
*/
_command MAS_Format_Column() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
int cur_mark = _alloc_selection('B');
_select_char(cur_mark);
int left_edge = p_left_edge;
int cursor_y = p_cursor_y;
_str search_options = "lh@";
int SearchStatus = 0;
_str Linje='',aMatch='';
// int dlgResult = textBoxDialog ('Format Column',0,5000,'Perl regular expressions','','','Eksisterende skilletegn:\t','Nye skilletegn: | ');
_param1=Siste_Skilletegn;
_param2=Siste_NySkille;
int dlgResult = textBoxDialog ('Format Column',0,5000,'Perl regular expressions','','','Eksisterende skilletegn:'Siste_Skilletegn,'Nye skilletegn:'Siste_NySkille);
_param2=stranslate(_param2,' ','\t','I');
Siste_Skilletegn=_param1;
Siste_NySkille=_param2;
int Start=0;
int End=0;
boolean Selected=false;
typeless Dummy;
if (_get_selinfo(Start,End,Dummy)) { // Sjekk om det er en selection og finn første kolonne
top();
} else {
search_options = search_options :+ "m";
Selected=true;
_begin_select();
}
int KolonneBredde[];
_str KolonneData[];
int i=0;
for (;;) { // Løp gjennom alle linjer for å finne maks kolonnebredde.
get_line(Linje);
KolonneData=MST_Split_To_StrArray(Linje,_param1);
for (i=0;i<KolonneData._length();i++) { // Sjekk alle kolonner
if (i == KolonneBredde._length()) { // Første gang må array elementet initialiseres
KolonneBredde[i]=KolonneData[i]._length();
} else { // har kolonnedata
if (KolonneData[i]._length() > KolonneBredde[i] ) { // Denne er større
KolonneBredde[i]=KolonneData[i]._length();
}
}
}
if (down()) break;
if (Selected) {
if (End == 1) {
if (_end_select_compare() >= 0) break; // Ikke ta med cursor linje hvis kolonne 1
} else {
if (_end_select_compare() > 0) break;
}
}
}
if (select_active()) { // Sjekk om det er en selection, og begynn på nytt.
_begin_select();
} else {
top();
}
_str NewLine='';
int Delta=0;
for (;;) { // Løp gjennom alle linjer for å justere kolonner
get_line(Linje);
KolonneData=MST_Split_To_StrArray(Linje,_param1);
NewLine='';
for (i=0;i<KolonneData._length()-1;i++) { // Sjekk alle kolonner
Delta=MST_Count_HighBit(KolonneData[i]); // MÃ¥ ta hensyn til norske tegn.
// Hvert tegn må ha +1 til bredde
NewLine = NewLine :+ _pad(KolonneData[i],KolonneBredde[i]+Delta,' ') :+ _param2;
}
NewLine = NewLine :+ KolonneData[i];
replace_line(NewLine);
if (down()) break;
if (Selected) {
if (End == 1) {
if (_end_select_compare() >= 0) break; // Ikke ta med cursor linje hvis kolonne 1
} else {
if (_end_select_compare() > 0) break;
}
}
}
_begin_select(cur_mark);
set_scroll_pos(left_edge, cursor_y);
_free_selection(cur_mark);
}
Thank you so much for your suggestions, really!
I tried to run your script (i'm an absolute beginner in Slickedit) but i couldn't.
What i've tried:
1)Created a .txt, pasted your code and saved as "test.e"
2)Opened Slickedit, went to Macro / Load Module, selected the "test.e" file and when i'm trying to open it, i get the following error:
Do you know why this message appears?
I really appreciate your help