How to compose region like “<?php foo; bar; ?>”

前端 未结 2 1343
感动是毒
感动是毒 2021-01-24 08:22

I want fold php block in php template file.

  

  

2条回答
  •  深忆病人
    2021-01-24 08:50

    So, you want to input a P and it should output something like ? Did I understand your question correctly?

    In that case, check out yasnippet (more info on emacswiki). It lets you define your own snippets (the syntax is really easy) like P, let it have placeholders (so you can replace xxx; and xxx; with something else when calling the snippet) and such. It's really handy. Just create a new snippet (the name of the file dictates it's shortcut, ie, name it P it this example) and input something like:

    # name: My own P-snippet.
    # --
    
    

    No need to make own font-locks, no need to use regexp. Just create a new snippet. After creating (and loading it, I usually restart emacs since I'm lazy) your snippet, open up a php-mode buffer, type P and press tab. Magic! :)

提交回复
热议问题