Preserving tab position (indent from the left) when editing multiline strings

Hello,

when i am coding in php - every time i press enter - cursor get moved to a correct position so i can write a new line content according to current indent i am at. However, this doesn't happen If i am adding new line to a multi line string. For example:

$execsql = "SELECT * 
FROM mytable
WHERE something = 'cool'";

When i type "FROM mytable" and hit enter, cursor gets its position at x=zero in new line while i would want it to be under the beginning of word "FROM". This dropping cursor at zero happens only within multiline strings.

Thanks in advance

2 comments
Comment actions Permalink

Hi there,

When i type "FROM mytable" and hit enter, cursor gets its position at x=zero in new line while i would want it to be under the beginning of word "FROM".

Works for me...

 

P.S.

  • In some cases Shift+Enter (Start New Line action) can do it better than just Enter.
  • Have you tried HEDOC/NOWDOC for such a code? May work better there... In particular with Flexible NOWDOC that is available PHP 7.3+ and that Shift+Enter shortcut in use.
    And If "SQL" tag name is used then the IDE will inject SQL language straight away instead of waiting until you get enough text inside the string to recognize it as SQL.

Such a code with have leading indent whitespace stripped by PHP so only a nicely formatted part will remain:

$execSQL2 = <<<SQL
SELECT *
FROM table
WHERE something = 'cool'
SQL;

The variable will contain the following (which is better looking than your multiline string will produce :) ):

SELECT *
FROM table
WHERE something = 'cool'
0
Comment actions Permalink

Thanks for your input. Shift + Enter does exactly what i need. Enter alone - nope, but that's okay. Sift+Enter also is good. Will also give HEDOC/NOWDOC a try! :) Thanks!

0

Please sign in to leave a comment.