Skip to content

A collection of Magento 2 code snippets for Visual Studio Code

Notifications You must be signed in to change notification settings

jerrylopez/vscode-magento2-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2 Snippets

A nice start to a collection of Magento 2 code snippets for Visual Studio Code!

Table of Contents

Layouts

Instructions
Attributes

Modules

Instructions

DI

Instructions

Events

Instructions

Routes

Instructions

Layouts

Instructions

Scaffold

Trigger: m2.layout

Output:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        
    </body>
</page>

Block

Trigger: m2.layout.block

Output:

<block class="" name="" as="" template="" />

Block Wrap

Trigger: m2.layout.blockWrap

Output:

<block class="" name="" as="" template="" />
    
</block>

Container

Trigger: m2.layout.container

Output:

<container name="" label="" output="0" htmlTag="" htmlId="" htmlClass="" />

Container Wrap

Trigger: m2.layout.containerWrap

Output:

<container name="" label="" output="0" htmlTag="" htmlId="" htmlClass="">
    
</container>

Reference Block

Trigger: m2.layout.refBlock

Output:

<referenceBlock name="">
    
</referenceBlock>

Reference Container

Trigger: m2.layout.refContainer

Output:

<referenceContainer name="">
    
</referenceContainer>

Move

Trigger: m2.layout.move

Output:

<move element="" destination="" />

Remove

Trigger: m2.layout.remove

Output:

<remove src="" />

Update

Trigger: m2.layout.update

Output:

<update handle=""/>

Arguments

Trigger: m2.layout.args

Output:

<arguments>
    
</arguments>

Argument

Trigger: m2.layout.argument

Output:

<argument name="" xsi:type=""></argument>

Attributes

Translate

Trigger: m2.layout.attr.translate

Output:

translate=""

xsi:type

Trigger: m2.layout.attr.xsi:type

Output:

xsi:type=""

Handle

Trigger: m2.layout.attr.handle

Output:

handle=""

Destination

Trigger: m2.layout.attr.destination

Output:

destination=""

Element

Trigger: m2.layout.attr.element

Output:

element=""

htmlId

Trigger: m2.layout.attr.htmlId

Output:

htmlId=""

htmlClass

Trigger: m2.layout.attr.htmlClass

Output:

htmlClass=""

htmlTag

Trigger: m2.layout.attr.htmlTag

Output:

htmlTag=""

Output

Trigger: m2.layout.attr.output

Output:

output=""

Label

Trigger: m2.layout.attr.label

Output:

label=""

As

Trigger: m2.layout.attr.as

Output:

as=""

Template

Trigger: m2.layout.attr.template

Output:

template=""

Class

Trigger: m2.layout.attr.class

Output:

class=""

Name

Trigger: m2.layout.attr.name

Output:

name=""

Before

Trigger: m2.layout.attr.before

Output:

before=""

After

Trigger: m2.layout.attr.after

Output:

after=""

Cacheable

Trigger: m2.layout.attr.cacheable

Output:

cacheable=""

Display

Trigger: m2.layout.attr.display

Output:

display=""

Remove

Trigger: m2.layout.attr.remove

Output:

remove=""

Modules

Module Instructions

Module XML

Trigger: m2.module

Output:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/module.xsd">
    <module name="" setup_version="0.1.0" />

</config>

Registration

Trigger: m2.module.registration

Output:

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '',
    __DIR__
);

DI

DI Instructions

DI Scaffold

Trigger: m2.di

Output:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
</config>

Preference

Trigger: m2.di.pref

Output:

<preference for="" type="" />

Type

Trigger: m2.di.type

Output:

<type name="">

</type>

Type Arguments

Trigger: m2.di.type.args

Output:

<arguments>
    <argument name="" xsi:type=""></argument>
</arguments>

Type Arguments Item

Trigger: m2.di.type.args.item

Output:

<item name="" xsi:type=""></item>

Plugin

Trigger: m2.di.plugin

Output:

<plugin name="" 
        type=""
        sortOrder=""/>

Virtual Type

Trigger: m2.di.virtualtype

Output:

<virtualType name="" type="">

</virtualType>

Events

Events Instructions

Events Scaffold

Trigger: m2.events

Output:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

</config>

Event

Trigger: m2.events.event

Output:

<event name="">

</event>

Observer

Trigger: m2.events.observer

Output:

<observer name="" instance="" />

Routes

Routes Instructions

Routes Scaffold

Trigger: m2.routes

Output:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">

</config>

Routers

Trigger: m2.routes.router

Output:

<router id="">
    
</router>

Route

Trigger: m2.routes.route

Output:

<route id="" frontName="">
    <module name="" />
</route>