Author Topic: Is there a way to indent relative to the previous line?  (Read 1136 times)

rjpontefract

  • Community Member
  • Posts: 46
  • Hero Points: 3
Is there a way to indent relative to the previous line?
« 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.

lhasadad

  • Community Member
  • Posts: 15
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #1 on: August 18, 2015, 11:05:51 pm »
I think you want: format-columns

rjpontefract

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #2 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.

lhasadad

  • Community Member
  • Posts: 15
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #3 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.

rjpontefract

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #4 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.

lhasadad

  • Community Member
  • Posts: 15
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #5 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


rjpontefract

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: Is there a way to indent relative to the previous line?
« Reply #6 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 :-)

rgloden

  • Senior Community Member
  • Posts: 166
  • Hero Points: 5
Re: Is there a way to indent relative to the previous line?
« Reply #7 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.