Actuarial Data Science

Bridging the Gap between Actuarial and Data Science

Sat 07 March 2020

Running code in VS Code with Ctrl + Enter: move to next line

Posted by Pieter Marres in Articles   

vscode

Over the last couple of months, there has been one single key stroke I have used over and over again in my coding projects. Ctrl + Enter allowed me to select and run any code block and move to the next line. This feature works out-of-the-box in RStudio but requires some tweaking in VS Code.

By the end of this post, Ctrl + Enter will make running your code blocks in VS Code much more convenient.

Step #1: Install the “macros” extension

  • In VS Code, hit View on the top menu.
  • Search for extension named “macros” (by geddski).
  • Install the “macros” extension.

Step #2: Add a few lines to keybindings.json

  • In VS Code, hit Crtl + Shift + P.
  • Enter in the search bar: JSON.
  • Select “Open Keyboard Shortcuts (JSON)”.

Add the following lines of code:

keybindings

Step #3: Add a few lines of code to settings.json

  • In VS Code, hit Crtl + Shift + P.
  • Enter in the search bar: JSON. Select “Open settings (JSON)”.

Add the following lines of code:

settings

Now you are ready to run your code line by line!

Click here if you prefer to copy-paste the snippets in this post into your own json files.

By now, the Ctrl + Enter keystroke should work just fine in your VS Code editor.

Enjoy running your selections of code!


 

Comments

blog comments powered by Disqus