fbpx

Visual Studio Code Tips and Tricks

Here are some of the most used key combinations and plugins we like for Visual Studio Code

How to remove extra line breaks

The key to removing line breaks is mastering Visual Studio’s search / replace box. Once you have opened the box wit Ctrl+h, then you must switch to regular expression with Alt+r. It’s best to experiment because different use cases present different solutions. For example, you could try these regular expressions:

$\n+

replace with

\n

Multiple Cursors

Probably one of the most useful used shortcuts for web design. Please ESCAPE when done not ENTER.

Choose Next In Selection

Ctrl + D

Everything in Selection

You can add additional cursors to all occurrences of the current selection with Ctrl+Shift+L.

Do your thing then press ESCAPE, not ENTER.

Reference Editing Hacks: https://code.visualstudio.com/docs/getstarted/tips-and-tricks

Close All Files

Ctrl+K W

Duplicate Line

Ctrl+C + Ctrl+V on empty line

Import a class file

Alt Ctrl+I (I for India)

Quickly Jump to Any File

Ctrl+P allows you to search for any file

Align Equals Signs

Use the Better Align plugin, then invoke “Align” on the command palette

Invoke the Command Palette

Ctrl+Shift+P

Format the Document (and fix indentation)

Ctrl+Shift+I

Refactor Code Block

In our experience this is document for Visual Studio code but doesn’t work as well as PHPStorm. Install this plugin:
https://marketplace.visualstudio.com/items?itemName=marsl.vscode-php-refactoring

The official documentation is here:
https://code.visualstudio.com/docs/editor/refactoring

And refers to a PHP plugin we don’t use (it has a poor rating):
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense

References

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top