Moving from WebStorm/Phpstorm to VS Code

Reading Time 5 min

Been a user of Phpstorm/webstorm since long and wish to migrate to VS Code ? Skeptical about changing your IDE or the changes that it might bring along ? Fear not, for we will show you how you could setup VS code to be identical to Phpstorm/webstorm.

Why should you migrate to VS Code ?

I love using Webstorm/Phpstorm and it has been the editor of my choice since several years now.  But here are a few advantages that I saw that compelled me try out VS Code  –
Webstorm/Phpstorm to VS Code

  • VS Code provides the same functionality as Webstorm/Phpstorm
  • Free of cost (thanks to Microsoft for making it Open Source)
  • It is fast. (In fact, faster than Webstorm/Phpstorm and lighter in terms of RAM usage)

Lets see how to get this IDE setup


Setting Up VS Code

Firstly, you should have installed VS Code. If you haven’t, do so by downloading it from its official source

By default, VS Code does not come with out-of-the-box support for many languages like PHP, Java, Ruby, etc or even frameworks like React, Vue, Svelte, Symfony, etc. Thankfully, there are extensions to support almost every language and framework.

You will find a list of useful extensions which are highly recommended to make your new IDE function just like Phpstorm/Webstorm. In general, to keep your IDE fast, the lesser the number of extensions, the better. Consequently, only the bare essential extensions have been listed.


Recommended Extensions

1. IntelliJ Keybindings

This extension ensures your transition to VS Code to be less cumbersome by allowing you to use the same keyboard shortcuts as you did with WebStorm/PhpStorm.
There are a few exceptions but its much better than having to learn new keyboard combinations all over.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install k--kato.intellij-idea-keybindings

2. IntelliSense for CSS class names in HTML

As the name suggests, this adds auto-complete support for css classes in your html files.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install Zignd.html-css-class-completion

3. Gitlens

Gitlens is a cool extension that can be used for all your git based tasks. Allows you to check a file’s history, annotate them, explore repositories, see and compare your stashed items and so on.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install eamodio.gitlens

4. Javascript Snippets

This extension installs handy javascript snippets to speed up your development. This gives you a functionality similar to that of Live Templates in Webstorm/Phpstorm. You can also add your custom javascript snippets at ~/.config/Code/User/snippets/javascript.json

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install xabikos.JavaScriptSnippets

5. Extensions to Support PHP

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install felixfbecker.php-pack
# ext install felixfbecker.php-intellisense
ext install bmewburn.vscode-intelephense-client
ext install felixfbecker.php-debug

6. Extensions to Support Symfony + Twig

  • Symfony – Adds debug/autocomplete support for Symfony
  • Twig – Adds support for Twig syntax
# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install TheNouillet.symfony-vscode    # adds symfony-support
ext install whatwedo.twig                 # adds twig-support

7. Linters

Highly recommended if you work with Typescript and/or Javascript.

  • TSLint – Adds support for TSLint
  • EsLint – Integrates ESLint JavaScript with VS Code
# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install ms-vscode.vscode-typescript-tslint-plugin
ext install dbaeumer.vscode-eslint

8. Docker

If you’re using docker, then this extension will be your ally. It helps you to build, manage, deploy and debug your containerized applications.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install ms-azuretools.vscode-docker

9. Reveal

This extension is the equivalent of the Select Opened File button found in PhpStorm/WebStorm. Its adds a similar button to allow you to quickly highlight an open file in the File Explorer/sidebar.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install smulyono.reveal

10. Code Formatting

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install esbenp.prettier-vscode
ext install EditorConfig.EditorConfig

11. Auto Rename Tag

As the name suggests, this extension will rename matching tags like <html></html> while you edit them. VS code does this automatically for html files but other file formats aren’t supported. To add support for every other format, use this extension. I find it very helpful while using frameworks like React, Vue, Svelte or any other frameworks that use JSX or even XML files.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install formulahendry.auto-rename-tag

12. Syntax Highlighting for Apache, yaml and dotenv

  • Apache Conf – Highlights syntax for apache configuration files
  • Yaml – Adds Yaml language support
  • Dotenv – Adds support for dotenv file syntax
# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install mrmlnc.vscode-apache
ext install redhat.vscode-yaml
ext install mikestead.dotenv

13. Settings Sync

Settings Sync helps you to synchronize your settings between multiple machines. Synchronizing settings has become absolutely essential for people in 2020 who are forced to toggle between work and work from home (thanks Corona!) NOTE: To sync settings, there exists a native way to do it within VS Code. I’d suggest using this recommended way instead of the extension. The extension nonetheless serves as an excellent alternate option.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install Shan.code-settings-sync

14. Rest Client

If you need to test your API without leaving your IDE, this extension does a great job. Its an alternative to using Postman or Insomnia for the same.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install humao.rest-client

15. Improve Code Readability

  • Bracket Pair Colorizer – This extension colorizes matching brackets. Update Sept 2021: Starting from version 1.60.* released this month, this is built into VS Code and can be enabled by updating the settings as seen at the end of this article
  • Indent Rainbow – Makes indentation easier to read by adding colours
# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install CoenraadS.bracket-pair-colorizer
ext install oderwat.indent-rainbow

Bonus: Custom Vscode Icons

This extension adds custom icons for files according to their extension. For example, package.json files will have an icon with npm written on it, thus making it easier to identify the file.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install vscode-icons-team.vscode-icons

Bonus Theme: Darcula IntelliJ Theme

Do you prefer Webstorm’s / Phpstorm’s Darcula theme ? If yes, then this extension is for you!

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install trinm1709.dracula-theme-from-intellij

Worthwhile mentions:

AI code Completion

This extension uses AI to autocomplete your code. It seems quite fun and interesting and is quite efficient at doing its job. Sometimes, you’re like how does it read my mind ? Feel free to try it out

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install TabNine.tabnine-vscode

Note: This extension can consume plenty of your computers resources, so if it slows down your system, better to avoid it. Also, as of the July 2021, the free version has a daily code completion limit (50 completions only) and also supports small projects (up to 100 source files.) So if you’re really into this extension, I recommend getting the PRO version.

CodeMetrics

This extension computes cyclomatic complexity in TypeScript / JavaScript files. Quite useful to keep code complexity in check.

# To install, Launch VS Code Quick Open (Ctrl+P) and execute the following
ext install kisstkondoros.vscode-codemetrics

I’m sure that there are tons of other extensions available at VS code’s marketplace. Feel free to try them out and if they’re worth it, recommend them to the dev community as well.


Update VS Code Settings

Once you’ve installed all the necessary extensions, its time to update the settings of your new IDE. To open the settings, you can use the File Menu (Preferences => Settings) or you could hit Ctrl + ,. This will open up your Settings. You can tinker with the settings as you’d like.

You can also update the settings.json directly. Hit Ctrl + Shift + P and type settings.json and then select Preferences: Open Settings (JSON).

You should now have your settings.json file on the screen and could update it as shown below. And you do not need to worry about updating settings of extensions that you haven’t installed. Because, in that case, those settings will simply have no effect. So you could directly copy-paste the following settings –

{
  "gitlens.views.lineHistory.enabled": false,
  "gitlens.views.search.enabled": false,
  "gitlens.views.compare.enabled": false,
  "gitlens.statusBar.enabled": false,
  "gitlens.hovers.enabled": false,
  "gitlens.blame.format": "${author|10} ${date}",
  "gitlens.blame.highlight.locations": ["gutter", "line", "overview"],
  "gitlens.blame.avatars": false,
  "gitlens.blame.compact": false,
  "gitlens.defaultDateFormat": "DD/MM/YYYY",
  "gitlens.defaultDateShortFormat": "DD/MM/YYYY",
  "gitlens.blame.heatmap.enabled": false,
  "gitlens.codeLens.enabled": false,
  "files.autoSave": "afterDelay",
  "workbench.iconTheme": "vscode-icons",
  "window.zoomLevel": 0,
  "editor.minimap.enabled": false,
  "editor.tabSize": 2,
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "modifications",
  "editor.renameOnType": true,
  "editor.linkedEditing": true,
  "editor.bracketPairColorization.enabled": true,
  "editor.guides.bracketPairs": true,
  "eslint.workingDirectories": [
    { "directory": "./client" }, // should point to the directory containing eslint config
    { "directory": "./www" }
  ],
  "editor.codeActionsOnSave": {
    // For ESLint
    "source.fixAll.eslint": true,
    // For TSLint
    "source.fixAll.tslint": true,
    // For Stylelint
    "source.fixAll.stylelint": true
  },
  "javascript.preferences.quoteStyle": "single",
  "typescript.preferences.quoteStyle": "single",
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
  "explorer.confirmDelete": false,
  "vsicons.dontShowNewVersionMessage": true,
  "prettier.printWidth": 120,
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "typescript.updateImportsOnFileMove.enabled": "always",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "svg.preview.mode": "svg",
  "workbench.startupEditor": "welcomePage",
  "workbench.statusBar.visible": true,
  "files.trimTrailingWhitespace": true,
}

Useful Keyboard Shortcuts

Here are a few new keyboard shortcuts that you might wanna learn to make your life easier.

  • Open command Palette => Ctrl + Shift + P OR F1 key
  • Open Settings => Ctrl + ,
  • Select all occurrences of Find match => Ctrl + Shift + L
  • Add selection/cursor to next match => Alt + J
  • Jump to matching bracket => Ctrl + Shift + \

To help with your transition, here’s a link to my VS Code Settings. You can most certainly use it as a reference. Also, once you finish setting up your new IDE, feel free to go through the official Tips & tricks.
Hope it helps 😉


References

Leave a Reply