Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

Smart Cut/Paste Spacing of declared variables and contants...

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Brunner
var
  iCount                            : Integer;
  Commands                     : TDatabaseCommands;
  iLcv,iWhatEver                : Integer;

When I declare variables I tend declare them one per line but not always. I also place my ":" at column 34.

When I cut/paste variables and they move from one level to another inside a method I find the smart feature starts them off properly but does not adjust the left side. To be REALLY smart and for declarations only, it would cool if the editor could remove some white space (if possible) between the end of the last declared variable and the colon.

procedure Test;
var
  iInt1,iInt2           : Integer;
  Test2                 : string;
  procedure SubTest1;
  var
     iInt1,iInt2        : Integer;
     Test2              : string;
  begin
  end;
begin
end;

Notice that when I take declarations from one spot I want the colons to be in alignment. If I could get that when I copy/cut paste I would be totally impressed :-)

Reply by email

Graeme Geldenhuys
to Andrew Brunner

Op 2010-10-20 15:24, Andrew Brunner het geskryf:

does not adjust the left side. To be REALLY smart and for declarations only, it would cool if the editor could remove some white space (if possible) between the end of the last declared variable and the colon.

What you are looking for is called "Elastic Tabstops". That feature will reproduce your expected behaviour exactly.

Website explaining it all:
http://nickgravgaard.com/elastictabstops/

Mantis feature request:
http://bugs.freepascal.org/view.php?id=9650

Search the mailing list archive for 'elastic tabstops'. There is an extensive discussion about this already. In short, it aligns text in the same block. Resize the text in that block or before that block, it automatically adjusts surrounding lines in the same block. The animated gif in the Elastic Tabstops website shows this nicely.

I unfortunately don't have the expertise to implement it - I tried but failed. :-(

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net:8080/fpgui/

Reply by email

Mattias Gärtner
to Andrew Brunner: var iCount : Integer; Commands :…

Zitat von Andrew Brunner :

Show quoted text 33 lines
var iCount : Integer; Commands : TDatabaseCommands; iLcv,iWhatEver : Integer; When I declare variables I tend declare them one per line but not always. I also place my ":" at column 34. When I cut/paste variables and they move from one level to another inside a method I find the smart feature starts them off properly but does not adjust the left side. To be REALLY smart and for declarations only, it would cool if the editor could remove some white space (if possible) between the end of the last declared variable and the colon. procedure Test; var iInt1,iInt2 : Integer; Test2 : string; procedure SubTest1; var iInt1,iInt2 : Integer; Test2 : string; begin end; begin end; Notice that when I take declarations from one spot I want the colons to be in alignment. If I could get that when I copy/cut paste I would be totally impressed :-)

The paste (without replace) only indents.
Note: With elastic tabs the above would work automatically. There is the idea to run the jcf formatter on pasted code. I'm not sure how good the jcf formatter works on snippets.

For automatic variable declaration it should be easy to implement. For example:

var
   i    : integer;
begin
   j:=1;  // ctrl+shift+c
var
   i    : integer;
   j    : integer;
begin
   j:=1;

You can create a feature request if you want.

Mattias

Reply by email

waldo kitty
to Andrew Brunner: var iCount : Integer; Commands :…
Andrew Brunner wrote
Notice that when I take declarations from one spot I want the colons to be in alignment. If I could get that when I copy/cut paste I would be totally impressed :-)

+1

but i gotta ask... what can/will be used to determine the column for the colons to align on? what happens if something on that line is longer and the colon must be pushed over? how far to push it over?

Reply by email

Graeme Geldenhuys
to waldo kitty

Op 2010-10-21 00:28, waldo kitty het geskryf:

but i gotta ask... what can/will be used to determine the column for the colons to align on? what happens if something on that line is longer and the colon must be pushed over? how far to push it over?

Elastic Tabstops will solve that too, by pushing all the other lines colon as well - always keeping them aligned.

I wonder how we an bride Martin (or somebody else with good SynEdit experience) to implement that gem. ;-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net:8080/fpgui/

Reply by email