In net beans you can quickly create templates for things like classes and assigned chunks of text to short cuts etc.
How can I do this in Sublime Text. I have looked around the net and can't find a simple example.
1) First of all make sure you have the correct syntax defined for the file you are working on (usually in the bottom right corner in sublime text).
2) Then be sure to have the cursor inside the <?php ?> tags.
3) Using your example of creating a class, simply start typing the keyword class and hit the tab or enter key to execute the existing, built-in snippet of sublime text.
4) You should see a basic code structure in your code now. Using the tab key again, you can jump through the snippet and adjust the parameters to your needs.
If you need more customized snippets, there is also the possibility of creating your own.
Go to Tools -> New Snippet... in the sublime menu. The syntax is difficult to describe, that's why I would recommend reading on about sublime snippets here:
http://docs.sublimetext.info/en/latest/reference/snippets.html
There are also many packages available for sublime that add extra snippets to your editor. Have a look here (be aware that you need Package Control installed):
https://sublime.wbond.net/browse
Cheers! Hope this helps!
Related
I'm editing a saved .php file in Sublime Text 3 (build 3126 for mac), and when I try to comment something out using cmd+/, Sublime inserts the standard HTML comment
<!-- -->
Sublime does not comment out when I try to use DocBlocks, /* */, # or //.
I've checked and Sublime is currently set to PHP syntax, as it should be. The Build System is set to Automatic. Has anyone ever experienced this and do you know of a fix? I couldn't find this problem anywhere on StackExchange and the only thing I found on Google was:
https://forum.sublimetext.com/t/cant-set-syntax-to-php/7478/8
Since their symptoms don't exactly match mine, I thought I'd ask here before I go as far as clearing caches that I don't know much about.
Maybe this answer is too simple, but it might be your case:
In SublimeText3 when opening comments using Ctrl+/ or Ctrl+Shift+/:
When editing brand-new empty saved .php file, sublime use HTML comments <\!-- -->
But when you open a PHP tag, AND your cursor is inside it, Sublime uses right PHP comments /* */ or //
So it's context sensitive. It uses PHP comments only inside PHP code fragments.
Remember that PHP opening tag is required even in pure PHP-code files.
How I can find and show all files in Phpstorm where this method
$this->other_model->any_method()
is called?
cmd+shift+f for Mac and ctrl+shift+f for Windows will find any piece of text throughout the project or directory. Or you could use alt+f7 to find usages.
PHPStorm Keyboard Mapping.
Viewing Structure of a Source File.
You can search for symbol with combination Ctrl+Shift+Alt+N. This combination allows you to search not only PHP classes/methods but also PHP variables, CSS classes etc.
If you want to find method usages in files:
click on your method and press Alt+F7
If you want to search any composition of your desire search, you can use from searching everywhere. I prefer to use this because PhpStorm makes it possible to look for any item of the source code, databases, actions, elements of the user interface, etc. in a single action.
to use that, only press search button in the right upper corner of phpStorm or 2 times press shift key on your keyboard. Now you can find your search everywhere. This is great functionality of phpStorm.
To read more information about using this search method, go to the following link:
Searching Everywhere
To See all the methods for search in phpStorm, Go to the following link:Searching Through the Source Code
I really like sublime but I have 1 major issue stopping me from migrating from Netbeans:
I need sublime autocomplete to show function description and method signature (i'm working with Yii framework and I need to know exactly what each function does, returns and passed arguments types).
I tried installing several plugins but none worked...if there is such a way then i'm missing it.
You are just in time for Sublime Text 3 !
Symbol Indexing. Sublime Text now scans the files in your project, and builds an index of which files contain which symbols. This backs the new features Goto Definition and Goto Symbol in Project, both of which are available from the Goto menu. Goto Definition takes you to the definition of the symbol under the caret, while Goto Symbol in Project prompts you to select a symbol via fuzzy matching, and then takes you to the definition of that symbol.
you might want to try the code intel plugin
available here
otherwise you could use zencoding see here for tips
alternatively alt + click should do it!
here's a relatively new plugin
dreamweaver has an option to automatically scan a directory and index all the user defined functions so you can then easily reference and auto complete when writing code. I am using notepad++ to right PHP and would like a similar feature without the need of manually updating an API or config file or anything for notepad++.
Does anyone know of a plugin/addon etc or maybe a better open source program which allows this feature?
Did you try Sublime Text 2? It's a really cool text editor, that implements natively what are you asking for.
isnt there any software/plugin to netbeans/eclipse that auto indent the whole code after i've inserted it?
not just indent when i press ENTER for new function.
i want to paste in a code for example without indents and it will auto indent everything automatically since it can recognize what language is used.
should save a lot of time.
In Zend Studio (and I guess in Eclipse with PDT as well), you can right click your pasted document in the editor view and select Source Format. Rules for source formatting are edited in Windows Preferences PHP Code Style Formatter. You can select Code Conventions like PEAR or ZF there by default or invent your own.
If you just want to indent some selected lines of code back and forth you select it and hit tab (or shift tab to unindent). This will not resolve any nested code though. Use Ctrl Shift F for that (thanks to Paul Lammertsma for pointing that out).
In Eclipse you can press Ctrl+Shift+f to autoindent your open file.
In Netbeans go to the Source menu, choose the Format option. It does what you need. It will follow the formatting options you set from Tools menu, Options dialog.
Polystyle is a standalone tool that can be integrated into most IDEs, and does highly configurable source code formatting for many languages. It costs $15.
I believe the Eclipse shortcut to auto-indent the selected code is Ctrl+i, at least it is in Eclipse for Java, so I assume it would be the same for Eclipse PHP.