question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code snippet control indentation

See original GitHub issue

How can I control unindentation in code snippets?

{
    "Create migration helper execute statement": {
        "prefix": "mhe",
        "body": [
            "\\$helper->execute(<<<SQL",
            "\t$0",
            "\rSQL",
            ");"
        ]
    }
}

When invoking it in indented context:

class Migration {
→   public function up(Helper $helper) {
→   →   mhe<tab complete snippet>
→   }
}

Expected behavior:

class Migration {
→   public function up(Helper $helper) {
→   →   $helper->execute(<<<SQL
→   →   →   |<cursor>
SQL
→   →   );
→   }
}

Actual behavior:

class Migration {
→   public function up(Helper $helper) {
→   →   $helper->execute(<<<SQL
→   →   →   |<cursor>
→   →   
→   →   SQL
→   →   );
→   }
}

This is invalid behavior when using heredoc.

I tried to insert \r <carriage return> to try removing all indentation, but it is just translated to a newline and indented according to snippet context.

  • VSCode Version: 1.9.0
  • OS Version: macOS Sierra

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:10
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Monk3yDevcommented, Mar 18, 2019

Is there any update for current case?

1reaction
Hezkorecommented, Jun 28, 2019

@thetrompf Well… my bug report was closed in reference to this issue. See #76139

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to indent/format a selection of code in Visual Studio Code?
I want to indent a specific section of code in Visual Studio Code: Select the lines you want to indent, and; use Ctrl...
Read more >
Code Blocks and Indentation | Flow of Control in Python
To indicate a block of code in Python, you must indent each line of the block by the same amount. The two blocks...
Read more >
Snippets wrong indentation - Visual Studio Feedback
The example add personal snippets to Code Snippet Manager of Visual Studio. The snippets can be invoked by shortcut or with menu (CTRL+K,...
Read more >
Copy with proper indentation - Visual Studio Blog
You want to share some code you've written with a colleague, so you select it in the editor and hit Ctrl + C...
Read more >
Indentation style - Wikipedia
Especially, it is used to clarify the link between control flow constructs such as conditions or loops, and code contained within and outside...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found