0

In VS Code, is there a way I can use keyboard combination like "ctrl+enter" to finish the current line and add { automatically at end of the line? instead of that i have to go to the end of the line my self and type { for it.

For example, when I typed if, VS code gives me if () blocks automatically, and I started typing condition in the braces.

if (condition) 
// while the cursor is after 'n' but before ')'  

When I'm at the end of the "condition", I have to use arrow key to move to the end and add {}. Do you program Javascript in this way or you have better tools/keyboard shortcut to use?

While I'm programming in Python, most IDE like VScode or Pycharm provides quick completion keyboard shortcut like "ctrl+shift+enter" to finish the line by adding ":" at end of the sentence, which applies to both defining functions, if, for, conditions. But unfortunately I haven't found such a way in Javascript world yet.

2 Answers 2

1

Search for snippets on the VS extension section ,I think you can find it there for any programming language .

Sign up to request clarification or add additional context in comments.

2 Comments

I have default vscode javascript snippets and prettier extension added. But not see they help in this case. Which snippets you suggest and what keyboard shortcut can trigger the autocompletion + move to new line in your case?
there is a couple of extensions : -- JavaScript (ES6) code snippets -- Beautify -- Auto Close Tag
0
  1. Install this Visual Studio Code extension: Complete Line
  2. Press the keyboard shortcut Ctrl+Shift+Enter

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.