SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: rjpontefract on August 18, 2015, 08:07:55 pm

Title: Is there a way to indent relative to the previous line?
Post by: rjpontefract on August 18, 2015, 08:07:55 pm
I have some code similar to the following except that it has many more lines:

Code: [Select]
struct pair pairs[] =
{
  { "value 1", 1 },
  { "value 100", 100 },
  { "value 25", 25 },
  { "value 3000", 3000 }
};

Is there a way to indent the second values in the initialiser so that they are all aligned as follows:

Code: [Select]
struct pair pairs[] =
{
  { "value 1",    1 },
  { "value 100",  100 },
  { "value 25",   25 },
  { "value 3000", 3000 }
};

I seem to recall using an editor in the past that had a "tab-relative" command that would indent the current position on a line to match the next non-space character on the previous line which would work nicely for this.

Any help would be appreciated.
Title: Re: Is there a way to indent relative to the previous line?
Post by: lhasadad on August 18, 2015, 11:05:51 pm
I think you want: format-columns
Title: Re: Is there a way to indent relative to the previous line?
Post by: rjpontefract on August 18, 2015, 11:24:59 pm
Thanks for the suggestion, that really helped.  I searched the help for "tab" and "indent" not format.  That'll teach me.
Title: Re: Is there a way to indent relative to the previous line?
Post by: lhasadad on August 18, 2015, 11:34:29 pm
There was also a macro I remember either in slickedit or a predecessor (the E series from IBM) that allowed a 'queuing' (?) (think that was in the macro name) characters after a selected character, etc.

an example would be if you told it to queue the text after a , and set it up so the , was to be queued a a particular column result would be when the , was seen in a line it would be aligned at column specified and with the rest of the text after that.
Title: Re: Is there a way to indent relative to the previous line?
Post by: rjpontefract on August 18, 2015, 11:38:21 pm
That sounds like it would be useful.  Maybe I'll have to find some time to get my hands dirty with Slick-C.  The command I was thinking of is "indent-relative" in Emacs.
Title: Re: Is there a way to indent relative to the previous line?
Post by: lhasadad on August 19, 2015, 12:31:38 am
found this prior discussion of the topic:  https://community.slickedit.com/index.php/topic,8744.0.html

Title: Re: Is there a way to indent relative to the previous line?
Post by: rjpontefract on August 19, 2015, 01:21:12 am
Thanks again, that's very helpful.  Time to give Google Translate's Norwegian support a work out :-)
Title: Re: Is there a way to indent relative to the previous line?
Post by: rgloden on August 23, 2015, 09:13:17 pm
Wow ... format-column is a nice find.

The other command I use is "align-selection-left" but not quite as nice as format_column.