Caret going back to the beginning of the line

Hello everybody,

I'm a new user of WebStorm and I really love it, but there is only one little detail that is driving me crazy.

If have a block of code indented with tabs like this:
     line1


     line2

If the caret is placed at the end of line1:

     line1|


     line2

And I tap the down arrow key on the keyboard, the caret goes to the beginning of next line:

     line1
|
     line2

I want it to go to the end of the line instead (the line actually contains a tab):

     line1
          |
     line2


I couldn't find a way to solve it in the preferences, any ideas ?


Thanks.
4 comments
Comment actions Permalink

Hi Yann,

If your 2nd line (the empty one) is really empty (no spaces/tabs) then that is exactly where cursor will go (beginning/real end of the line).

You have "kind of" 2 options here:

  1. Instead of pressing "Down" key use "Enter" (that's, of course, if you at the end of the first line) -- in this case new line will be created with proper indents (and you can delete extra line by pressing "Del" key)
  2. Enable "Virtual space" -- this allows to place cursor in places where no characters are currently inserted (Settings | Editor | Allow placement of caret after end of line). This will not give you exact behaviour though, since caret will be moved in exactly the same column, just 1 line below.


Other than that -- there is no such option that would do exactly as you described. In any case -- check other options available on "Settings | Editor" screen.

1
Comment actions Permalink

Hi Andriy,
thanks for your answer.

  1. Instead of pressing "Down" key use "Enter" (that's, of course, if you at the end of the first line) -- in this case new line will be created with proper indents (and you can delete extra line by pressing "Del" key)
  2. Enable "Virtual space" -- this allows to place cursor in places where no characters are currently inserted (Settings | Editor | Allow placement of caret after end of line). This will not give you exact behaviour though, since caret will be moved in exactly the same column, just 1 line below.


I don't really wanna do 1) since I just want to move around the code, and I tried two and it has over side effects that I don't like (you can place the cursor on places where there are no spaces or tabs).


If your 2nd line (the empty one) is really empty (no spaces/tabs) then that is exactly where cursor will go (beginning/real end of the line).

Actually, my second line actually contains a tab.
I activated the "show spaces" settings and my code looked like this:

------>line1
------>
------>line2


Which is what I want, and in this situation, the caret behaves as expected.

Doing this however, I noticed that the tab on the second line got automatically removed when I saved the file !

I am going to look more into this, maybe I can deactivate this auto cleaning feature.
0
Comment actions Permalink

Settings | Editor | Strip trailing spaces on Save

0
Comment actions Permalink

Perfect, thank you very much !

0

Please sign in to leave a comment.