Recent

Author Topic: Pretty Printing - pretty formatting as one uses the editor?  (Read 9681 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
I think I saw a thread in this forum, that there's a short cut to pretty-print the code one is working on, but I can't seem to find that anymore.

So is there a shortcut as said?

Or, how to have pretty printing, maybe even automatically as one uses the editor?

Thanks.
« Last Edit: July 22, 2011, 09:40:07 am by Elmug »

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #1 on: July 21, 2011, 08:52:35 am »
I think I saw a thread in this forum, that there's a short cut to pretty-print the code one is working on, but I can't seem to find that anymore.
You mean automatic formatting? That would be ctrl-D; this runs the Jedi Code Formatter on the active file in the editor.

Gr.
Dirk.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #2 on: July 21, 2011, 09:18:00 am »
I think I saw a thread in this forum, that there's a short cut to pretty-print the code one is working on, but I can't seem to find that anymore.
You mean automatic formatting? That would be ctrl-D; this runs the Jedi Code Formatter on the active file in the editor.

Gr.
Dirk.


Thank you Dirk.

That does it.

However, after formatting the text, the cursor moves to the last line of code.

Is there a way so that after formatting, the cursor stays in the same line (or close enough)?

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #3 on: July 21, 2011, 10:25:58 am »
Elmug, I don't think so... I've never seen it mentioned in any documentation anyway...

As a workaround you could try to set a bookmark, format the code and go back to the bookmark. Haven't tested this though...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #4 on: July 21, 2011, 11:06:18 am »
Elmug, I don't think so... I've never seen it mentioned in any documentation anyway...

As a workaround you could try to set a bookmark, format the code and go back to the bookmark. Haven't tested this though...

Thanks BigChimp..I did thought of something like you suggest, but it mostly does not matter that much.

The first time I tried CTL-D I thought something drastic had happened, and I was at the end of the code.

It's OK, I like it after using it some more.

Thanks everyone!

Elmug

  • Hero Member
  • *****
  • Posts: 849
Isn't it a little strange tha a Pascal Unit does not have a BEGIN and so there's an orphan "END. " at the end?

I just noticed that with the pretty-printing CTRL-D. :(


DirkS

  • Sr. Member
  • ****
  • Posts: 251
Isn't it a little strange tha a Pascal Unit does not have a BEGIN and so there's an orphan "END. " at the end?
It's a bit of a strange one, but it's not really an orphan because units always need an 'end'.
I think the official syntax actually allows a 'begin', but it can be omitted when there's no code.

BTW: there are more constructs that have an 'end' without 'begin': record, class, ...

Gr.
Dirk.


Elmug

  • Hero Member
  • *****
  • Posts: 849
Isn't it a little strange tha a Pascal Unit does not have a BEGIN and so there's an orphan "END. " at the end?
It's a bit of a strange one, but it's not really an orphan because units always need an 'end'.
I think the official syntax actually allows a 'begin', but it can be omitted when there's no code.

BTW: there are more constructs that have an 'end' without 'begin': record, class, ...

Gr.
Dirk.

Thanks for the clarifications, Dirk.  Am not that hard-headed to exceptions, and often I wish I were even less  ;)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Pretty Printing - pretty formatting as one uses the editor?
« Reply #8 on: July 22, 2011, 09:39:50 am »
I do have another question on formatting the code:

Sometimes when pressing CTRL + D to format the text, instead of due formatting, a screen called JCF Parse Tree shows up, and no formatting takes place.

I would appreciate some help on why this could be so.

Thanks!

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #9 on: July 22, 2011, 10:19:14 am »
Quote
Sometimes when pressing CTRL + D to format the text, instead of due formatting, a screen called JCF Parse Tree shows up, and no formatting takes place.
That means that the JCF has problems parsing the code. You should also see a message about that in the Messages window.

Gr.
Dirk.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Pretty Printing - pretty formatting as one uses the editor?
« Reply #10 on: July 22, 2011, 12:22:42 pm »
Thanks.

You are right.

I have been having some problems with readability of my text, but I believe that will change for I've no been told how to change the font size of the editor, and I have already changed it.

 

TinyPortal © 2005-2018