Menu

Code alignment 10

2014-09-20
2014-12-17
  • Chris McGrath

    Chris McGrath - 2014-09-20

    Code Alignment for Notepad++

    Hi Everyone,
    Been a while since I've posted here.
    I've just released Code alignment 10. Download from http://www.codealignment.com/downloads/CodeAlignmentNpp_10_0.zip

    It's been a while since I've updated the Notepad++ version - last version I posted was v6. The main changes are you can now import and export settings and "Alignment Chaining".

    Alignment Chaining: When using the Code alignment shortcut, simply keep pressing control and you can immediately perform another alignment starting from where the last alignment occurred.
    For more information and change log check out http://www.codealignment.com

    I've updated the plugin repository with the details. The reason I haven't bothered updating the plugin manager with v7, 8 & 9 is in the past I released several versions where approval usually took months and I put out a new version by then. I understand and appreciate people are busy and are doing this in their own time, but I really did find this off putting. If you could update the Plugin Manager it would be appreciated.

    Code Alignment is open source and available on github - https://github.com/cpmcgrath/codealignment/wiki

     

    Last edit: Chris McGrath 2014-09-20
  • THEVENOT Guy

    THEVENOT Guy - 2014-09-21

    Hello Chris,

    I downloaded your last version 10 of CodeAlignment, two days ago. I take some time to read your documentation. and do some tests.

    It's really an awesome plugin, very powerful but, however, very easy to use. Of course, I had to find out the exact keys, on my French keyboard, for your list of proposed shortcuts, pressed after CTRL + =. Anyway, it was an opportunity to test it fully :-) I'll about to post this list on the French forum !

    In a test text of several lines, containing, both, spaces and/or tabulations, I tried to align by the letter e, a very common letter, in French :

    • With all options by default

    • With the Use IDE tab settings for alignments option

    Really incredible ! The two texts looks identical, although the alignment is mainly realized with spaces, in the first case, and with tabulations, in the second case :-)) Don't know how you can achieve it so brightly !


    An example : you would like to clearly identify the different styles of each language, in the stylers.xml file, of a Notepad++ configuration. Quite easy with CodeAlignment :

    • Copy the stylers..xml configuration file, as a new file Test.xml

    • Open Test.xml in Notepad++ ( I supposed that Codealigment 10 is already installed ! )

    • Select the option Plugins - Code alignment - Align by... or pressed the CTRL + SHIFT + = shortcut

    • Type styleID, with that exact case

    • Click on the OK button

    Et voilà ! Much more readable, isn't it ?

    Of course, you must use a monospaced font ( such as Courrier New, Consolas or Lucida Console ), in order that CodeAlignment works properly !

    Follow the link below, relative to a ( non exhaustive) list of fixed, or monospaced, fonts for Notepad++ ! :

    https://sourceforge.net/p/notepad-plus/discussion/331753/thread/5c8c669b/#2143


    Chris Mc Grath, may I suggest one small improvement :

    Would it be possible to include, in the two dialogs Align by... and Align from caret, the Add space option, like in the Options - Shortcuts dialog ?

    I'm referring at the end of your article Example 2 : Align by string, at the address :

    https://github.com/cpmcgrath/codealignment/wiki/Example-2:-Align-by-string

    So, it wouldn't be necessary to add an extra space, after the colon, in your example !

    Oh, a last question :

    Of course, the Align by equals option line up text to the next = sign, found in the bloc, but what is the option Align by equals equals for ? I couldn't find out anything about it :-( May be, I miss something obvious !


    Again, many thanks for that awesome plugin !

    Best Regards,

    guy038

    P.S. : I'll make a donation very soon ! Quite normal for that wonderful tool !

     

    Last edit: THEVENOT Guy 2014-09-21
  • Chris McGrath

    Chris McGrath - 2014-09-21

    Hi,
    Thanks for your kind words, they are always appreciated.

    As for the key labeling problem, I've had it reported before and have raised this issue - Issue 22

    If you're able to respond to the issue with more information, I'd be happy to fix it up.

    If you use the shortcut Ctrl = backspace The screen will launch with the Align from Caret ticked (Note: I just noticed a small bug where this launches the dialog in a stupid location - Issue 30) I'm also planning on making the Align by string align from caret if you hold SHIFT when OK is pressed (Issue 23).

    As for Align by equals equals, it's a bit of a legacy thing (The standard keyboard shortcuts don't include it) but the idea was if you had code like...

    int someVar = Foo();
    if (someOtherVariable == 5
    &&  someVar == 6)
    {
    

    You could turn it into

    int someVar = Foo();
    if (someOtherVariable == 5
    &&  someVar           == 6)
    {
    

    But most of the time I just select the lines and do an align by equals or align by space.

     

    Last edit: Chris McGrath 2014-09-21
  • THEVENOT Guy

    THEVENOT Guy - 2014-09-22

    Hi, Chris,

    On a very old MS-DOS book, I saw the keyboard layouts of twenty countries about. Unfortunately, no one is identical :-(( So, management of key's strokes, at hardware level, should not be used. But I'm not a coder and I can't give you some hints about it ! But, don't worry, we just have to test, once only, 25 keys about to get it :-)

    I posted, on the French forum, the list of the CodeAlignment's shortcuts and the effective matched keys, on a French keyboard. Hope that this will save time to others guys :-)

    I did see the odd location of the dialog, when using the Align from caret option, but I wouldn't say that a bug ! Moreover, this tiny issue happens ONLY when you use the shortcut CTRL + =, Backspace. If you use the option Plugins - CodeAlignment - Align from caret, the dialog is quite centred on the screen.

    In my last post, I forgot to thank you for the new Alignment Chaining feature of the version 10 ! It's really a "plus" and a time saver :-)

    OK, I clearly see, now, the difference between the two options Align by equals and Align by equals equals. The effects of the align by space, by equals and by equals equals, below, from your example ( cursor is located at the beginning of the second line ) :

    //------- ORIGINAL Text -----------------------------
    
    int someVar = Foo();
    if (someOtherVariable == 5
    &&  someVar == 6
    
    //------- CTRL + = , CTRL + SPACE (3 times )---------
    
    int someVar            =  Foo();
    if  (someOtherVariable == 5
    &&  someVar            == 6)
    
    //------- CTRL + = , CTRL + = (1 time )--------------
    
    int someVar           = Foo();
    if (someOtherVariable == 5
    &&  someVar           == 6
    
    //------- CTRL + = , CTRL + = (2 times )-------------
    // ( The DOUBLE equals are separated with a SPACE ! )
    
    int someVar           = Foo();
    if (someOtherVariable = = 5
    &&  someVar           = = 6)
    
    //------- Option Align by "equals equals" -----------
    
    int someVar = Foo();
    if (someOtherVariable == 5
    &&  someVar           == 6)
    
    //----------------------------------------------------
    

    BTW, Chris, I'm a bit worried concerning my donation because, on the page for payment, it just proposes to pay in Australian dollars and I suppose that I can only pay in Euros, with my French credit card ! How to do ?

    Cheers,

    guy038

    P.S. : I totally agree with you, concerning the tabulations / spaces problem. If someone is interested about that discussion, just click on the link below :

    https://github.com/cpmcgrath/codealignment/wiki/Tabs-&-Alignment

     

    Last edit: THEVENOT Guy 2014-09-22
  • Davey

    Davey - 2014-09-28

    Hi and thanks for the plugin
    I used to enjoy this plugin very much, but for a while now I have been getting an error message saying that it is not compatible with my version of n++
    I thought that the new update would fix that problem, but I am still getting this message.

    I am running n++ v6.5.2 on Windows 7
    I would appreciate any help on this

    Thanks
    Davey

     
    • Chris McGrath

      Chris McGrath - 2014-12-14

      Hi Davey,
      Sorry about the delay. This is most likely caused by not having .NET 3.5 installed.

       
      • Davey

        Davey - 2014-12-17

        Hi Chris
        Thanks for your reply!
        I have .Net 4.5 installed - do I have to download 3.5?