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

rjpontefract

  • Senior Community Member
  • Posts: 250
  • Hero Points: 10
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

  • Senior Community Member
  • Posts: 250
  • Hero Points: 10
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

  • Senior Community Member
  • Posts: 250
  • Hero Points: 10
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

  • Senior Community Member
  • Posts: 250
  • Hero Points: 10
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: 169
  • 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.