简体   繁体   English

Sublime Text 3-PHP-对象运算符和双箭头运算符

[英]Sublime Text 3 - PHP - object operator and double arrow operator

Recently I've begin moving to sublime text 3 from Netbeans. 最近,我开始着手从Netbeans升华文本3。

I've discovered almost all needed features but still can't find one. 我发现了几乎所有需要的功能,但仍然找不到。

There is a cool feature in Netbeans: 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 -> . 仅需按一下-签名就足够了,Netbeans自己弄清楚应该是->。 The same is applied to array. 同样适用于数组。

I understand that Sublime doesn't do as deep code analysis as Netbeans does. 我知道Sublime不像Netbeans那样进行深度代码分析。

Of course it would perfect solution if it could figure out like Netbeans does. 当然,如果可以像Netbeans一样弄清楚,它将是完美的解决方案。

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. 我不敢相信所有人每次都会手动键入-并按shift +>来引用该对象。 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. 尽管ST是一个很酷的编辑器,但它只是编辑器,它对Netbeans很烂的js,scss,css,python很有用,但对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. 如果我不知道使用成熟的IDE可以得到更大的提升,我可能会对ST for PHP感到满意。

So frontend development will be carried on ST and backend on Netbeans. 因此,前端开发将在ST上进行,后端将在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 与关键- -要更换>在崇高文本任何情况下(这意味着如果你想写点什么,比如1 - 2 ,你必须键入1   - backspace - 退格键   2 , you can do the following: 2 ,您可以执行以下操作:

  • From the Preferences menu in Sublime Text 从Sublime Text中的Preferences菜单
  • Click Keybindings - User 单击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.) 写下[{ "keys": ["-"], "command": "insert", "args": { "characters": "->" } }] (请注意,这假定您还没有任何东西(如果要这样做,请在文件末尾的[ ]]键入,以及上面的字符,且不要包含[]字符。该文件必须是有效的JSON键盘绑定数组。)
  • 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. 您可能可以对上下文进行一些魔术操作,以仅对PHP语法文件获取此键绑定,或者您可以编写一个简单的Python插件即可执行该键绑​​定,如果该插件不是PHP文件,则将在文档中输入- ->如果是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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