dongyan3616 2013-02-14 14:07
浏览 75
已采纳

编写<?php echo ...?>的最快方法

There are many questions on stack exchange on whether or not you should use <?php echo ?> or <?= ?>.

I have decided to use <?php echo ?>, but am wondering if there is a good way to create a shortcut to save time writing this.

Currently I use a default setup of Sublime Text 2, with no plugins or anything installed, I'm not a "super user". But I do know that if I type php then press tab it outputs: <?php ?>.

Is there a way to get an echo inside this, and is it a good idea to do this? Has anyone done this already?

PS I should add, I don't always want the echo to appear, as I won't always be needing to echo something.

  • 写回答

5条回答 默认 最新

  • doushi7761 2013-02-14 14:24
    关注

    You can bind a snippet to a keystroke.

    <snippet>
        <content>
            <![CDATA[<?php echo ${1:What to echo}; ?>]]>
        </content>
        <description>Basic echo</description>
    </snippet>
    

    Save the above as echo.sublime-snippet in your Packages/User folder then edit Default (OS of your choice here).sublime-keymap and add

    { "keys": ["command+e"], "command": "insert_snippet", "args": {"name": "Packages/User/echo.sublime-snippet" } }

    Swap out command-e for any key combination you want to use. Now, when you hit command & e Sublime will add in <?php echo ;?> for you and put the insertion cursor right before the ; for you - you can then start to type in what ever needs echoed.

    You can also replace ${1:What to echo} with $TM_SELECTED_TEXT and Sublime will wrap the text you've selected with <?php echo & ;?> when you highlight text and hit command & e.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?