NO

Author Topic: Sorting lines in editor  (Read 7248 times)

YellowBeast

  • Guest
Sorting lines in editor
« on: May 03, 2014, 07:47:15 PM »
I like to sort the #include'd header files.

It would be nice if the editor in Pelles C would allow you to select text, then sort its lines.
(For example, in Sublime Text 2 the F9 key sorts selected lines.)

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Sorting lines in editor
« Reply #1 on: May 04, 2014, 01:49:34 AM »
I like to sort the #include'd header files.

It would be nice if the editor in Pelles C would allow you to select text, then sort its lines.
(For example, in Sublime Text 2 the F9 key sorts selected lines.)
Doesn't make much sense to me....  ???

Sort by what criteria?

Ralf

YellowBeast

  • Guest
Re: Sorting lines in editor
« Reply #2 on: May 04, 2014, 08:46:16 AM »
Doesn't make much sense to me....  ???

Sort by what criteria?
Sort alphabetically. For example:

Code: [Select]
#include <string.h>
#include <float.h>
#include <stdio.h>
#include <stddef.h>

// would become

#include <float.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

By ordering the lines, it can be easier to check which headers are included.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Sorting lines in editor
« Reply #3 on: May 04, 2014, 10:41:08 AM »
Sounds like a very specialized feature - for you, and probably only you. No thanks.
An add-in could do the job.
/Pelle

Manos

  • Guest
Re: Sorting lines in editor
« Reply #4 on: May 04, 2014, 10:50:54 AM »
Sometimes a header file needs to be first than others.
Changing the order you will take errors.

Manos.

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Sorting lines in editor
« Reply #5 on: May 04, 2014, 12:00:33 PM »
By ordering the lines, it can be easier to check which headers are included.

That makes sense, but keep in mind Manos' point (although normally the order shouldn't matter - if you have redefinitions, then the header files need to be controlled).

Anyway, attached a simple exe that sorts the clipboard. It asks for confirmation to replace the clipboard with its sorted version.

Assembler source is included, *.asc = *.rtf, opens inter alia in WordPad and MS Word.

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Sorting lines in editor
« Reply #6 on: May 05, 2014, 05:01:49 AM »
Sometimes a header file needs to be first than others.
Changing the order you will take errors.

Manos.
+1
Actually quite a lot of times, the order of the header files might be important and just sorting the header files out of laziness is much more likely to create dependency problems...
I am programming in C for a bit more than 30 years now and can not say that I have run into a single case where that would have been helpful...

Ralf

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Sorting lines in editor
« Reply #7 on: May 05, 2014, 07:45:07 AM »
Code: [Select]
#include <windows.h>
#include <commctrl.h>
May the source be with you

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Sorting lines in editor
« Reply #8 on: May 05, 2014, 08:57:29 AM »
Point taken. Thanks, Timo.

Grincheux

  • Guest
Re: Sorting lines in editor
« Reply #9 on: March 07, 2016, 07:55:25 PM »
Some times I use the editor to edit a file but if I must sort the lines I copy them and paste into Notepad++ the I recopy to Pelle's editor. There is simpler.