php snippets

30 views
Skip to first unread message

caruso_g

unread,
Oct 3, 2009, 5:57:40 AM10/3/09
to xptemplate
Hi,
I am just learning Vim (MacVim) and I really love its philosophy. I
used TextMate on Mac for several years, so I was really addicted to
its bundles and looking for a good substitute in Vim I found SnipMate,
SnippetEmu, and XP template.
Between them, I love (guess who…?) XPT but trying to work with it in a
index.php file I am not able to use php snippets, while html ones work
great. (btw, repeated snippets and nested ones are brilliant!)
It is surely my fault, but I am not able to figure how to make php
snippets work. Can you help me please?

Kent Sibilev

unread,
Oct 3, 2009, 6:55:33 PM10/3/09
to xptem...@googlegroups.com


Make sure that you use these snippets inside of <?php ?> context.

Kent

caruso_g

unread,
Oct 4, 2009, 2:40:24 AM10/4/09
to xptemplate
Hi Kent,
thanks, it seems working, but is there a php trigger (i.e. php+tab=<?
php |cursor| ?>)?
If not, how can I do it?
I am lazy… :D

On Oct 4, 12:55 am, Kent Sibilev <ksr...@gmail.com> wrote:

dr-dr xp

unread,
Oct 4, 2009, 5:47:36 AM10/4/09
to xptem...@googlegroups.com
There is no 'php' trigger in the latest version. You can use abbreviation or mapping to do this, in vim, :help abbr
It is better to add one snippet for "<?php ..?>". :)

To your previous question, That should not happen in the latest 0.3.9.6 version. If the filetype is detected by vim, snippets are loaded well. And now it should not depend on any context like '<?php'

I need some more information to find out what's going wrongly. First is the filetype, when you edit index.php without <?php ?>, what do you get if you type
:set filetype?

If vim tells you 'php', I need your vim version and .vimrc file to search for the problem.
--
要了几天饱饭就不记得西北风啥味了

Ben Glassman

unread,
Sep 8, 2012, 2:48:03 PM9/8/12
to xptem...@googlegroups.com
Hello,

Sorry to raise a dead post and first off thanks for all your work on a wonderful plugin.

I am running into the same issue where I cannot trigger PHP snippets unless I am in the context of <?php tags. This is fine for many of the snippets but I have a desire to create snippets for entire pages (a view template for example) which would be easier if I could just invoke the snippet without needing the starting <?php tag

Your response seems to indicate that this is how it should behave, but perhaps that has changed between 0.3.9.6 and 0.4.8

Is this possible?

I am running 
XPTemplate: 0.4.8
VIM: 7.3

dr-dr xp

unread,
Sep 9, 2012, 12:26:22 AM9/9/12
to xptem...@googlegroups.com
It is possible if what you want is like this:
<body>
#trigger-php-for-loop-here#
<?php ...

and you should get:
<body>
for ( $arr as ....
<?php ...

I am not on my own pc right now. later around I will have a check about this issue and give you the exact solution.

--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To view this discussion on the web visit https://groups.google.com/d/msg/xptemplate/-/XjOhrupNmn4J.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.



--
要了几天饱饭就不记得西北风啥味了

Ben Glassman

unread,
Sep 9, 2012, 8:00:06 PM9/9/12
to xptem...@googlegroups.com
I am actually trying to start with a blank file with filetype set to php and use the template on the first empty line.

On line 0 of the doc..

view_index<C-\>

and have that expand to my template

dr-dr xp

unread,
Sep 11, 2012, 3:33:06 AM9/11/12
to xptem...@googlegroups.com
Within an empty file, the filetype on your at your cursor position is "HTML". Thus to add your snippets to html.xpt.vim should solve this problem.

BTW like javascript in html, XPT supports nested filetypes. You have different snippet set at different position.

To view this discussion on the web visit https://groups.google.com/d/msg/xptemplate/-/FezY1ekdhbAJ.

To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.



--
要了几天饱饭就不记得西北风啥味了
Reply all
Reply to author
Forward
0 new messages