Tapatalk

PHP completion 'a la' TextMate

PHP completion 'a la' TextMate

1
NewbieNewbie
1

    Apr 24, 2006#1

    Many of the devs working with Windows have been dying lately because of the "fast completion" feature provided by the MacOs TextMate editor, largely demonstrated in screencasts all over the web, and unfortunately UltraEdit didn't provide such a tool until today.

    The power of the macros allow for exactly the same feature.

    Here is what it does:

    if+TAB

    Code: Select all

    <?php if(): ?>
       
    <?php endif; ?>
    else+TAB

    Code: Select all

    <?php else: ?>
    foreach+TAB

    Code: Select all

    <?php foreach($ as $): ?>
       
    <?php endforeach; ?>
    echo+TAB

    Code: Select all

    <?php echo ?>
    This is really useful for writing PHP templates with UltraEdit. Of course, it preserves the original function of the TAB key and indentation. When using the Macro, you will also notice that the cursor is placed exactly where you need it.

    Here is the marco, to be affected to the 'TAB' key (remember to turn the 'continue serach' checkbox on):

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    UnixReOn
    IfSel
    Find RegExp "^"
    Replace All SelectText "  "
    Else
    IfExtIs "php"
    "PHPCOMPPHP"
    Key Ctrl+LEFT ARROW
    Find "echoPHPCOMPPHP"
    Replace All "<?php echo  ?>"
    IfFound
    Loop 11
    Key RIGHT ARROW
    EndLoop
    EndIf
    IfNotFound
    Find RegExp "^(\s*)ifPHPCOMPPHP"
    Replace All "\1<?php if(): ?>
    \1  
    \1<?php endif; ?>"
    IfFound
    Loop 9
    Key RIGHT ARROW
    EndLoop
    EndIf
    IfNotFound
    Find RegExp "^(\s*)foreachPHPCOMPPHP"
    Replace All "\1<?php foreach($ as $): ?>
    \1  
    \1<?php endforeach; ?>"
    IfFound
    Loop 15
    Key RIGHT ARROW
    EndLoop
    EndIf
    IfNotFound
    Find RegExp "^(\s*)elsePHPCOMPPHP"
    Replace All "\1<?php else: ?>
    \1"
    IfFound
    Loop 4
    Key RIGHT ARROW
    EndLoop
    Key DOWN ARROW
    EndIf
    IfNotFound
    Find "PHPCOMPPHP"
    Replace All "  "
    Key Ctrl+RIGHT ARROW
    EndIf
    EndIf
    EndIf
    EndIf
    Else
    "  "
    EndIf
    EndIf
    
    This code is brought to you by the symfony project. For updates of this macro and more productivity tools for PHP devs, visit the project website.