Author Topic: Aligning stuff with multiple cursors  (Read 654 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2288
  • Hero Points: 197
  • Text
Aligning stuff with multiple cursors
« on: October 26, 2020, 06:49:04 pm »
There should be a way to get all the cursors on each line to be aligned.
A special <space> or <tab> that would insert the minimum number of spaces on each line to line them up.

This wouldn't work if you have multiple cursors on a single line of course.

Starting with
Code: [Select]
    AThings_Name;
    AnotherName;
    SimpleName;
Set three cursors.
Delete the trailing ";"
Select the three words, copy.
<End>
<Tab>
=
<Tab>
<Paste>
The results look like this:
Code: [Select]
    AThings_Name    =   aThings_Name;
    AnotherName =   anotherName;
    SimpleName  =   simpleName;

Ideally, the "="s would all get aligned.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3396
  • Hero Points: 465
Re: Aligning stuff with multiple cursors
« Reply #1 on: October 28, 2020, 05:42:55 pm »
I generally do this sort of thing by creating space to the right, then moving to the beginning of the line and cursoring to the column where I want to insert, then clean up the end with a Ctrl+E (cut-end-line)

Code: [Select]
    AThings_Name              |
    AnotherName              |
    SimpleName              |

<Home>
Code: [Select]
    |AThings_Name             
    |AnotherName             
    |SimpleName             

<Right to aligned column>

Code: [Select]
    AThings_Name |
    AnotherName  |
    SimpleName.  |

=
<Space>
<Paste>
;

Code: [Select]
    AThings_Name = aThings_Name;|
    AnotherName  = anotherName;|
    SimpleName.  = simpleName;|

Finally, <cut-end-line> or <delete-end-line>

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3396
  • Hero Points: 465
Re: Aligning stuff with multiple cursors
« Reply #2 on: October 28, 2020, 05:44:58 pm »
For what it's worth, you do have a good idea, I'd like to have an "end-align-columns" command that moved all the cursors to the column corresponding to the longest line, that would definitely save a couple steps.  I am going to file a feature request for that.

jporkkahtc

  • Senior Community Member
  • Posts: 2288
  • Hero Points: 197
  • Text
Re: Aligning stuff with multiple cursors
« Reply #3 on: October 28, 2020, 07:52:12 pm »
To go along with this ... cursor commands to skip over white space.
Or begin-word, end-word commands.
Frequently, prev-word/next-word go too far.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3396
  • Hero Points: 465
Re: Aligning stuff with multiple cursors
« Reply #4 on: October 28, 2020, 07:58:57 pm »
Added a note to the defect for end-word.  We already have a begin-word command.