PHP Surround
Wrap blocks of PHP code quickly! 🚀
A fork of the Surround extension
How To Use
After selecting the code block, you can
- right click on selected code
- OR press (ctrl+shift+T) or (cmd+shift+T)
List of commands
Command |
Snippet |
surround.with (ctrl+shift+T) |
List of all the enabled commands below |
surround.with.if |
if ($condition) { ... } |
surround.with.ifCondition |
if (...) { $code } |
surround.with.ifElse |
if ($condition) { ... } else { $else } |
surround.with.tryCatch |
try { ... } catch (\Exception $exception) { $catchBlock } |
surround.with.foreach |
foreach ($1 as $2) { ... } |
surround.with.for |
for ($i = 0; ... ; $i++) { ... } |
surround.with.arrowFunction |
fn ($params) => ... |
surround.with.functionDeclaration |
function $name ($params) { ... } |
surround.with.comment |
/** ... */ |
surround.with.region |
#region $regionName ... #endregion |
Options
showOnlyUserDefinedSnippets
(boolean): Disables default snippets that comes with the extension and shows only used defined snippets.
showRecentlyUsedFirst
(boolean): Recently used snippets will be displayed on top.
showUpdateNotifications
(boolean): Shows notification when there is a new version of the extension.
Configuration
Editing/Disabling existing wrapper functions
Go to "Settings" and search for "surround.with.commandName".
Example surround.with.if
:
{
"label": "if",
"description": "if ($condition) { ... }",
"disabled": false,
"snippet": "if(${1:condition}) {\n\t$TM_SELECTED_TEXT\n}$0"
}
Adding new custom wrapper functions
Go to "Settings" and search for surround.custom
and edit it like below.
{
"surround.custom": {
// command name must be unique
"yourCommandName": {
// label must be unique
"label": "Your Snippet Label",
"description": "Your Snippet Description",
"snippet": "burrito { $TM_SELECTED_TEXT }$0", // <-- snippet goes here.
"languageIds": ["html", "javascript", "typescript", "markdown"]
},
// You can add more ...
}
}
IMPORTANT NOTES:
- All command names and labels must be unique. If you do not provide a unique command name or label, your custom wrapper functions will override existing ones.
- You can redefine all snippets as long as you provide a valid
SnippetString
. Read More