Sublime Forum

[Variable completion] / php

#1

Hello,

I discovered Sublimetext after reading an article through a mac developpers website.

As I use until now textedit and also coda, I’m searching for a better php editor.

Sublimtext seems to have major advantages with auto completion feature but, cause
I switched to Mac 5 years ago, I cannot find the best features of my old Windows phpDesigner
(mpsoftware.dk/).

1/ Sublimtext is very good 'cause it’s light and fast (compared to Coda / Textedit / Komodo
or netBeans)

2/ Sublimtext missed a terrible feature : autocompletion right after the $ character (for dummy
variables $i, $j) or $_ (post / get / session / …)

Do you think that the 2nd feature will be released ???

Thank you,

Vincent

0 Likes

#2

Shouldnt be a problem for you, to create a plugin wich provides this functionallity. Even if you have no experience with python it isnt that hard to understand!
By the way, its fun to create plugins :wink:

0 Likes

#3

Add the following to your user keybindings:

[code] “auto_complete_triggers”:

	{
		"characters": "$",
		"selector": "source.php"
	}
][/code]

Autocomplete by default only triggers when typing letters and numbers; however, this setting allows you to add language-specific special characters. In this case, $.

0 Likes

#4

Hello,

I opened the Preferences -> User Key binding and add the following code :

[code]“auto_complete_triggers”:

	{
		"characters": "$",
		"selector": "source.php"
  }

]
[/code]
But when I save it, I’ve got the error message :

Error trying to parse file: Unexpected trailing characters in ~/Library/Application Support/Sublime Text 2/Packages/User/Default (OSX).sublime-keymap:1:25

What’s wrong with it ?

Thank you,

Vincent

0 Likes

#5

If there were settings in the file, you’ll have to add commas between the keys, like so:

{
    ...
    "some_other_setting": "value",
    "auto_complete_triggers":  { "characters": "$", "selector": "source.php" } ]
}
0 Likes

#6

Ok, it’s perfect ! I made a mistake and tried to implement it into keybinding instead of settings -> users !

Sublime Text won a battle versus Coda / TextMate…

Now, how to autocomplete $POST and $ prefixed variables.

–> I answer to myself --> TAB key after _ key is quite good ! (a laiziest keymap on _ would be preferable
but it’s acceptable)

Thank you

Vincent

0 Likes