Pelles C forum

Pelles C => Feature requests => Topic started by: YellowBeast on May 03, 2014, 07:47:15 PM

Title: Sorting lines in editor
Post by: YellowBeast 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.)
Title: Re: Sorting lines in editor
Post by: Bitbeisser 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
Title: Re: Sorting lines in editor
Post by: YellowBeast 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.
Title: Re: Sorting lines in editor
Post by: Pelle 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.
Title: Re: Sorting lines in editor
Post by: Manos 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.
Title: Re: Sorting lines in editor
Post by: jj2007 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.
Title: Re: Sorting lines in editor
Post by: Bitbeisser 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
Title: Re: Sorting lines in editor
Post by: TimoVJL on May 05, 2014, 07:45:07 AM
Code: [Select]
#include <windows.h>
#include <commctrl.h>
Title: Re: Sorting lines in editor
Post by: jj2007 on May 05, 2014, 08:57:29 AM
Point taken. Thanks, Timo.
Title: Re: Sorting lines in editor
Post by: Grincheux 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.