NO

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

YellowBeast

  • Guest
Sorting lines in editor
« on: May 03, 2014, 06: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: 754
Re: Sorting lines in editor
« Reply #1 on: May 04, 2014, 12: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, 07: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: 1923
    • http://www.smorgasbordet.com
Re: Sorting lines in editor
« Reply #3 on: May 04, 2014, 09: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

Offline Manos

  • Member
  • *
  • Posts: 35
    • The Coder's Corner
Re: Sorting lines in editor
« Reply #4 on: May 04, 2014, 09: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: 441
Re: Sorting lines in editor
« Reply #5 on: May 04, 2014, 11:00:33 AM »
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: 754
Re: Sorting lines in editor
« Reply #6 on: May 05, 2014, 04: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: 1555
Re: Sorting lines in editor
« Reply #7 on: May 05, 2014, 06:45:07 AM »
Code: [Select]
#include <windows.h>
#include <commctrl.h>
May the source be with you

Offline jj2007

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

Offline Grincheux

  • Member
  • *
  • Posts: 170
  • Never be pleased, Always Improved
    • Today, it's yestirday and Tomorrow
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.
-------------------
Today, it's yestirday and Tomorrow
Kenavo