Here are some of the most used key combinations and plugins we like for Visual Studio Code
Table of Contents
Collapse Outline
<Ctrl>
+ <LeftArrow>
will collapse the entire list making browsing so much easier.
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
Generate TOC
Install Markdown All in One. This pretty much takes care of automatically table of contents if the markdown is structured like this:
- [Filament AdminPanelProvder](#filament-adminpanelprovder) - [Tenant Model](#tenant-model) # Filament AdminPanelProvder ```php ->tenant(Tenant::class) ``` # Tenant Model ```php class Tenant extends Model ```
Run command “Create Table of Contents” (in the VS Code Command Palette) to insert a new table of contents.
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)
As of 11 January 2025, that shortcut doesn’t work on a Mac. I tried various other “google searches” but it didn’t find anything. Ironically, I went over to installing PHP Intelephense which apparently has a premium feature that will help. This helped, because now all of a sudden it picked up that the class file has an issue.
But before I even contemplated looking for a new shortcut, GitHub Copilot helped me out.
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 (control-shift-i for India). This doesn’t work on Mac after Copilot is installed because it bring up Copilit.
So use Shift Option F
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
Other Plugins
- GitHub Pull Requests by GitHub
- DotENV by mikestead
- Laravel Extension Pack by Winnie Lin
- Laravel Snippets by Winnie Lin
- PHP Debug by Xdebug
- PHP Intelephense by Ben Mewburn
- YAML
- Better PHPUnit by calebporzio
- DevDb by Damilola Olowookere
- EditorConfig for VS Code by EditorConfig
- Git Graph by mhutchie
- GitHub Actions by GitHub
- GitHub Copilot by GitHub
- GitHub Copilot Chat by GitHub
- Jira and Bitbucket(Atlassian Labs) by Atlassian
- Laravel Artisan by Ryan Naddy
- Laravel Blade formatter by Shuhei Hayashibara
- Laravel Blade Snippets by Winnie Lin
- Laravel Blade Wrapper
- Laravel Create View
- Laravel Extra Intellisense
- Laravel goto view
- laravel-goto-components
- laravel-jump-controller
- PDF Preview
- php cs fixer
- PHP Namespace Resolver
- rust-analyzer
- Tailwind CSS IntelliSense
- Vue – Official
- WakaTime
- XML Tools
You start small and then you end up with a great big mess.
All we really need is:
- WakaTime
- Laravel (Official)
- GitHub Copilot (which also installs GitHub Copilot Chat)
- Tailwind CSS IntelliSense
Our remaining problem when using Laravel is that we cannot refactor easily (or at all!) as we can in PhpStorm, but this problem will also be overcome.
References
- https://github.com/microsoft/vscode/issues/53262
- https://stackoverflow.com/questions/36350324/visual-studio-code-delete-all-blank-lines-regex
- https://stackoverflow.com/questions/38727047/duplicate-line-in-visual-studio-code
- https://marketplace.visualstudio.com/items?itemName=wwm.better-align
- https://code.visualstudio.com/docs/getstarted/userinterface