News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Sorting lines in editor

Started by YellowBeast, May 03, 2014, 07:47:15 PM

Previous topic - Next topic

YellowBeast

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.)

Bitbeisser

Quote from: 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.)
Doesn't make much sense to me....  ???

Sort by what criteria?

Ralf

YellowBeast

Quote from: Bitbeisser on May 04, 2014, 01:49:34 AMDoesn't make much sense to me....  ???

Sort by what criteria?
Sort alphabetically. For example:

#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.

Pelle

Sounds like a very specialized feature - for you, and probably only you. No thanks.
An add-in could do the job.
/Pelle

Manos

Sometimes a header file needs to be first than others.
Changing the order you will take errors.

Manos.

jj2007

Quote from: YellowBeast on May 04, 2014, 08:46:16 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.

Bitbeisser

Quote from: 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.
+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

TimoVJL

#include <windows.h>
#include <commctrl.h>
May the source be with you

jj2007


Grincheux

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.