简体   繁体   中英

Sublime Text 3 - PHP - object operator and double arrow operator

Recently I've begin moving to sublime text 3 from Netbeans.

I've discovered almost all needed features but still can't find one.

There is a cool feature in Netbeans: 在此处输入图片说明

It does the following. If I have such code:

$product = new Product;
$product->someMethod();

I don't need actually to type - and then shift + > to get -> . It's enough just to presss - sign and Netbeans figures out on his own that it should be -> . The same is applied to array.

I understand that Sublime doesn't do as deep code analysis as Netbeans does.

Of course it would perfect solution if it could figure out like Netbeans does.

But I would happy to replace - sign on numpad keyboard to -> always.

I've tried snippets. It looks like this: 在此处输入图片说明

It works ok. But only if it goes as the first symbol in the word. But then I need to reference an object referencing never goes first.

I can't believe that all people type manually every time - and shift+> to get referencing the object. There must be better way.

Any ideas? How did you tackle this problem?

Looks like there is no silver bullet which would kill any beast.

Though ST is a cool editor it's just editor, it's good for js, scss,css, python where Netbeans sucks but too bad for php.

Probably I would be happy with ST for PHP if I didn't know that you can get more boosting using full-blown IDE.

So frontend development will be carried on ST and backend on Netbeans.

Edit

Of course I tried the whole bunch of available plugins. This is the list of tried: 在此处输入图片说明

To replace the - key with - > in all situations in Sublime Text (meaning if you want to write, for example 1 - 2 , you would have to type 1   - backspace   2 , you can do the following:

  • From the Preferences menu in Sublime Text
  • Click Keybindings - User
  • Write [{ "keys": ["-"], "command": "insert", "args": { "characters": "->" } }] (note that this assumes that you don't already have anything in the user keybinding file. If you do, before the ] at the end of the file, type , and the above without the enclosing [ and ] characters. The file needs to be a valid JSON array of keybindings.)
  • Save it
  • Try typing - and see the magic

You may be able to do some magic with contexts to get this keybinding only for PHP syntax files, or you could just write a simple Python plugin that your keybinding would execute, which would enter - in the document if it is not a PHP file and -> if it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM