Shortcut/feature for prepending $this automatically in Intellij/Phpstorm - intellij-idea

Is it possible/does such feature exist that when I write an instance variable name (without $this->) it would search for a declared variable? I think it would save a bit of time not writing $this-> anytime I need to access an instance variable.

Currently such functionality is not available in PhpStorm.
https://youtrack.jetbrains.com/issue/WI-19345 -- watch this ticket (star/vote/comment) to get notified on progress.
Right now I may only suggest to write custom Live Template that would convert t[TAB] (or whatever abbreviation you desire) to $this-> with code completion popup already shown.
Related: https://youtrack.jetbrains.com/issue/WI-551

If all you need is save yourself the trouble of writing $this->, join the club. :) Macros are here for rescue.
I solved this problem by recording a Macro and then binding it with a keyboard shortcut:
Go to Edit | Macros | Start Macro Recording
Type '$this->'
Stop Macro Recording using the button in the lower right corner, then name it whatever you want.
Assign Shortcut to it:
Go to File | Settings | Keymap | Macros
Right click and choose 'Add Keyboard Shortcut'
I chose Ctrl+. as the shortcut and now I am more than happy. :)
I have answered a similar question here

Related

intelliJ automatically formating variables first

with ctrl-alt-L I can format the code of a class which works fine.
Is there also a shortcut to automatically sort codelines so the variables comes first and methods later ?
The action for this is Rearrange Code in the Code menu. It does not have a shortcut assigned by default, but you can assign one in Settings | Keymap.

Can NetBeans autoreplace text as I type?

I have Gedit set up with snippets, so that when I type XXXTab it automatically replaces xxx with exit(__FILE__ . ': ' . __LINE__);. Is there any way to achive the same effect in NetBeans? Searching for autocorrect or ways of replacing text finds me other, unrelated features.
Yes it has , but you should do your owns, there is someones that are already built inside netbeans, go to Tools - Options - Code Templates
There you can edit your owns or just use the default ones, this is the window
if i write Pfm and press tab it auto completes
Side note:
if you want to autoComplete while you are writing just go to the left tab Code Completion

Adapt the extend selection in IntelliJ

Everyone knows that when you select some text in IntelliJ and press Ctrl+w your selection is expanded.
However,
you're kinda stuck on the presets for this:
when you have following code:
<a4j:commandButton execute="#form" render="tableProperties"
value="#{cjr_main.addExtractType}"
action="#{ExtractTypesBean.addExtractType()}"
styleClass="bigButton"
oncomplete="setLineAdded();"/>
and "Line" is selected but the method setLineAdded() is not yet defined you'd want "setLineAdded()" to be selected after hitting ctrl+w a couple of times.
However
Once "setLineAdded" is selected, and you press ctrl + w the whole tag is selected in stead of the accompanying "()"'s...
Is there a way to get this behavior?
(without writing a whole IntelliJ plugin just for this?)
best regards,
S.
No, the behavior of extend selection is controlled by code and is not configurable by users. You can indeed write a plugin to change the behavior.

What is the name of the keyboard shortcut &/or method in an IDE which allows me to jump past automatically generated </endtags>?

This question relates to a prior question which was answered for all practical purposes with a fellow telling me I simply needed to press the "End" key to skip the cursor to the end of the line. But a second respondee told me of other IDE's abilities to this (his words): "In some IDE, pressing the tab key will move your cursor to the next placeholders in the currently auto replaced element, and if there is no more placeholders, brings you past the end of the auto replaced text."
What is this ability called?
I'll show an example very quickly, if you or I were writing some code in Aptana or RubyMine (my two favorite IDE's)...
<table summary="Subject detail view">
<tr>
<th>Name*</th>**
</tr>
</table>
We'd eventually run into the location(*), where the single asterisk is. We would reach this point and be forced to either use our mouse to click past the auto-generated </endtag>, or our keyboard arrows, or, most recently, the "End" key which would skip our cursor to the end of the line.
But can't I just do this with tab like my friend told me? In order to be able to do this I need to know what this keyboard shortcut is called. I need a searchable keyword. Any additional feedback about keyboard/IDE shortcuts etc would also be appreciated.
RubyMine (and IntelliJ IDEA platform it's based on) doesn't have this feature yet. There is an open feature request in the YouTrack issue tracker:
IDEA-74666 Add Eclipse Style Paren/Bracket/Quote Completiton
I have figured out the king of all answers for this question, which is my own.
Create your own macro. It is stupid how easy this is to do (with Komodo Edit, at least).
To do this in Komodo Edit, for example, first set yourself up so your cursor is a position where you need the custom command, whatever that might be.
So, let's say your at the end of an xml tag with your cursor where this ("|") symbol is
<xmltag>blahblah|</xmltag>
Now the < /endtag> has been generated automatically, just to make sure you know that.
Now, go to Tools, Macros, Start Recording. Click it. relax, you can do this as many times as you like...it only records keystrokes, by the way, so do this only with your keyboard. To skip to the end of the tag without the arrow keys, use the 'End' key. And I don't mean to insult your intelligence, but in case you didn't know this, you need to use the End key and not the arrows because future tags could be any length.
OK so do this:
<xmltag>blahblah</xmltag>
|
So you're there. Good, now go to Tools, Macros, and stop the recording.
Next, click on tools, macros, and save the macro.
Then, go to your macro library (same tools submenu) and you should see in the toolbox the file which you named which contains your macro.
Right click it, Properties, Key Bindings tab, then set your custom command in the 'new' form. Apply. OK. You're done.
Test it out, and pat yourself on the back, you just learned something really, really, really useful.
Btw, here's another one I've created.
<!-- | -->
That is a macro command as well. Obviously, you could create an entire form with a simple macro command.

Saving a position while coding?

Back in olden times, I used to code with an editor that allowed you to mark where you were in the code with a keypress. You could jump to another point in the same or another file to check a reference or somesuch. When you were ready, you could hit another keypress and return to the point you saved.
I've long since migrated to Dreamweaver and wanted this functionality. Does it exist in DW? If so, I missed that part of the manual. If not, any suggestions on an editor that DOES have that functionality?
Scott.
There is no official way to do it, but you could use the code collapse feature to create something like a bookmark. Collapse the single line and DW will have a mark at that line number until you clear it.