Questions about indentation and auto completes.

When PHPStorm offers to auto complete something, is there a way for it to remove what was previously there? Currently, if it auto completes, it will leaves remants of what was there. So if you have an autocomplete offered for $this->new_var while replacing $this->var_original, I will get "$this->new_varvar_original" It leaves var_original there  even though that is exactly what is being replaced by the auto complete.

Is it possible to code fold/hide /* */ comments automatically while keeping // comments visible?

How can I turn off the auto completion of phpdoc comments when I type /* (hit enter). This gives me (with the spaces):
/*
*
*/
I don't want this auto complete at all. I use comments too much and try to make them look nice but instead I am wrestling with the editor as it always gives be me this format. I looked under live templates but it wasn't there to replace.

I have many indentation problems in the editor. (I don't know if it matters, but I use tabs.) Here are two to start:

1) How do I make the home key go to either the beginning of the correct indentation for a line, or to the beginning fo the first character on the line? For me, right now it goes allllllll the way to the left to the very beginning of the line. (Although I'd like to retain this behavior, maybe by mapping it to a different key than home).

2) When I press the down arrow on a line that IS indented and go to a blank line below it (a line I pressed enter on before), my cursor goes to the beginning of the line, instead of the correct indentation. How do I stop this behavior?

4 comments
Comment actions Permalink

Hi there,

Would be extremely good if you could enumerate all of your questions .. otherwise it's difficult to see where one ends and another starts (yes, I'm lazy)

When PHPStorm offers to auto complete something, is there a way for it to remove what was previously there? Currently, if it auto completes, it will leaves remants of what was there. So if you have an autocomplete offered for $this->new_var while replacing $this->var_original, I will get "$this->new_varvar_original" It leaves var_original there   even though that is exactly what is being replaced by the auto complete.

Use [TAB] instead of [ENTER]

Is it possible to code fold/hide /* */ comments automatically while keeping // comments visible?

Well .. there is "Settings | Editor | Code Folding" -- it has "Documentation comments" -- may work, although I doubt that it will do exactly as you want (it meant to collapse Doc comments only that usually located before function/class/etc and should not touch comments inside the function body or alike).

How can I turn off the auto completion of phpdoc comments when I type /* (hit enter). This gives me (with the spaces):

Add SPACE before pressing ENTER: /*[SPACE][ENTER]

1) How do I make the home key go to either the beginning of the correct indentation for a line, or to the beginning fo the first character on the line? For me, right now it goes allllllll the way to the left to the very beginning of the line. (Although I'd like to retain this behavior, maybe by mapping it to a different key than home).

Settings | Editor | Smart Keys | Home

2) When I press the down arrow on a line that IS indented and go to a blank line below it (a line I pressed enter on before), my cursor goes to the beginning of the line, instead of the correct indentation. How do I stop this behavior?

I'm not 100% sure what exactly you want here. But the following option should do the job: "Settings | Editor | Allow placement of caret after end of line"

0
Comment actions Permalink

Thank you Andriy! (And you did correctly parse my questions!)

1) So TAB takes care of my first question.

2) The second question looks like it doesn't have a solution within the editor's default settings. Hopefully code can be folded according to user-defined regex at some point. i'd like to be able to fold '/*' comments, or maybe '#' or '<--' in html, but not '//' (or whatever).

3) "Add SPACE before pressing ENTER: /*[SPACE][ENTER]"
I am hoping to turn off this behavior, not work around it. Is there a way to shut if off completely? (Preferably, I'd like the option to customize the recognition of this behavior, rather than just eliminate it, but I am fine with turning it off and on completely, if that is all there is.)

4) Four was not very clear, sorry. Here are the steps to reproduce the problem:

make a new file test.php.

Type (don't copy) the following in it (do NOT type the (click here) part, I am just putting it here to show you where you need to click)

<?php

if ($test)
{
    echo '1';
    (click here)
    echo '2';

}

If you click while the file is still open, after having typed it by hand, on the line (click here), the cursor will be at the correct indentation (which is right below e in the first echo,and above the e in second echo).
But if you save, close, and re-open the file and click on (click here), the cursor will be at the absolute beginning of the line. I want it to appear at the correct point of indentation.

0
Comment actions Permalink
I am hoping to turn off this behavior, not work around it. Is there a way to shut if off completely? (Preferably, I'd like the option to customize the recognition of this behavior, rather than just eliminate it, but I am fine with turning it off and on completely, if that is all there is.)

You cannot turn it off.

But you may create Live Template with /* as abbreviation that would expand to a desired text. When expanding, the Live Template will have priority over such built-in completion.

Hopefully code can be folded according to user-defined regex at some point.

There is no such functionality (regex or the original request). You may submit Feature Request ticket directly to the Issue Tracker (check for existing tickets first)

But if you save, close, and re-open the file and click there, the cursor will be at the absolute beginning of the line. I want it to appear at the correct point of indentation.

The already mentioned option will solve this problem as it allows to place cursor anywhere -- even after end of line.

In any case: by default, when file is saved, all trailing space characters got removed. This behaviour can be controlled via "Settings | Editor | Strip trailing spaces on Save"

0
Comment actions Permalink

I will try the Live Template option you mentioned in reference to the /* problem. That's a great solution, thanks.

I will submit a ticket at some point.

The original solution you provided actually required me to hit the exact space I wanted with the cursor instead of clicking anywhere on the line. At that point, it's going to actually increase clicks/keystrokes to get what I want unless I want to take the time to be unusually precise with the mouse!
"Settings | Editor | Strip trailing spaces on Save" seems to have solved the problem, though. Thanks.

0

Please sign in to leave a comment.