Illuminated Cloud includes the following live templates:
Legend: italicized = user-provided underlined = template-provided cursor = final resting place of cursor
Apex Live Templates
Live Template | Description | Example |
dfr | Symbolic constant for DescribeFieldResult | SObjectType.SObjectType.fields.SobjectField.getDescribe() cursor |
dsr | Symbolic constant for DescribeSObjectResult | SObjectType.SObjectType.getDescribe() cursor |
dw | do / while statement | do { cursor } while (condition); |
fail | Assert a negative condition in a unit test | System.assert(false, cursor); |
for | for statement | for () { cursor } |
fori | Create for loop with index | for (Integer loopVariable = 0; loopVariable < upperBound; loopVariable++) { cursor } |
if | if statement | if (condition) { cursor } |
ife | if / else statement | if (condition) { cursor } else { } |
ifn | "if null" statement | if (selectedVariable == null) { cursor } |
ifnn | "if not null" statement | if (selectedVariable != null) { cursor } |
inst | "instanceof" check and downcast | if (selectedVariable instanceof SelectedType) { SelectedType castVariableName = (SelectedType) selectedVariable; cursor } |
itar | Create for loop for elements of an array | for (Integer loopVariable = 0; loopVariable < selectedArray.size(); loopVariable++) { ArrayElementType elementName = selectedArray[loopVariable]; cursor } |
iter | Create for loop for elements of an array, List, Set, or Map (keys or values) | for (CollectionElementType elementName : selectedCollection) { cursor } |
itli | Create for loop for elements of a List | for (ListElementType elementName : selectedList) { cursor } |
itme | Create for loop for entries of a Map | for (SelectedMapKeyType keyVariableName : selectedMap.keySet()) { SelectedMapValueType valueVariableName = selectedMap.get(keyVariableName); cursor } |
lazy | Lazy instantiation | if (selectedVariable == null) { selectedVariable = new SelectedVariableType(cursor); } |
lst | Fetch the last element of an array | selectedArray[selectedArray.size() - 1]cursor |
nl | Construct a new List and assign to a local variable | List<ElementType> newListName = new List<ElementType>();cursor |
nm | Construct a new Map and assign to a local variable | Map<KeyType, ValueType> newMapName = new Map<KeyType, ValueType>();cursor |
ns | Construct a new Set and assign to a local variable | Set<ElementType> newSetName = new Set<ElementType>();cursor |
pro | Create read-only property getter and setter | { get; private set; } |
prw | Create read/write property getter and setter | { get; set; } |
psf | Begin declaration of a public static final field | public static final |
psfi | Begin declaration of a public static final Integer field | public static final Integer |
psfs | Begin declaration of a public static final String field | public static final String |
ritar | Create a for loop for elements of an array in reverse order | for (Integer loopVariable = selectedArray.size() - 1; loopVariable >= 0; loopVariable--) { ArrayElementType elementName = selectedArray[loopVariable]; cursor } |
ritli | Create a for loop for elements of a List in reverse order | for (Integer loopVariable = selectedList.size() - 1; loopVariable >= 0; loopVariable--) { ListElementType elementName = selectedList.get(loopVariable); cursor } |
sa | Assert a condition in a unit test | System.assert(cursor); |
sae | Assert that a value is an expected value in a unit test | System.assertEquals(cursor); |
san | Assert that a value is null in a unit test | System.assertEquals(null, cursor); |
sane | Assert that a value is not an expected value in a unit test | System.assertNotEquals(cursor); |
sann | Assert that a value is not null in a unit test | System.assertNotEquals(null, cursor); |
sd | Debug logging | System.debug(cursor); |
SEL | Create a SOQL query | SELECT fields cursor FROM SObjectType |
SEL* | Create a SOQL query with all scalar fields | SELECT allFields FROM SObjectType cursor |
sq | Create a static SOQL query in Apex | [SELECT fields cursor FROM SObjectType] |
sqbit | Batch iterate the results of a SOQL query in Apex | for (List<SObjectType> results : [SELECT fields cursor FROM SObjectType]) { for (SObjectType result : results) { } } |
sqit | Iterate the results of a SOQL query in Apex | for (SObjectType result : [SELECT fields cursor FROM SObjectType]) { } |
sqm | Assign the results of a SOQL query to a Map in Apex | Map<Id, SObjectType> resultsById = new Map<Id, SObjectType>([SELECT fields cursor FROM SObjectType]); |
sqv | Assign the results of a SOQL query to a List in Apex | List<SObjectType> results = [SELECT fields cursor FROM SObjectType]; |
sqv1 | Safely assign the results of a single-row query to a variable in Apex | List<SObjectType> results = [SELECT fields cursor FROM SObjectType LIMIT 1]; SObjectType result = results.size() == 1 ? results.get(0) : null; |
sra | Generate a System.runAs(User) statement | System.runAs(user) { cursor } |
St | String | String cursor |
tc | try / catch statement | try { cursor } catch (ExceptionType e) { } |
tcf | try / catch / finally statement | try { cursor } catch (ExceptionType e) { } finally { } |
tf | try / finally statement | try { cursor } finally { } |
thr | Throw an exception | throw new ExceptionType(cursor); |
wh | while statement | while (condition) { cursor } |
Lightning Web Components Live Templates
Live Template | Description | Example |
importitems | Imports one or more exports from the specified module | import { items cursor } from 'module'; |
importdefault | Imports the default export from the specified module | import alias from 'module'; cursor |
importapex | Imports an @AuraEnabled Apex class member | import alias from '@salesforce/apex/class.member'; cursor |
importobject | Imports an SObject | import alias from '@salesforce/schema/sobject'; cursor |
importfield | Imports an SObject field | import alias from '@salesforce/schema/sobject.field'; cursor |
importlightning | Imports one or more exports from a standard LWC (lightning namespace) component | import { items cursor } from 'lightning/component'; |
importcomponent | Imports one or more exports from a custom LWC component | import { items cursor } from 'c/component'; |
importresource | Imports a static resource URL | import alias from '@salesforce/resourceUrl/resource'; cursor |
importasset | Imports a content asset URL | import alias from '@salesforce/contentAssetUrl/asset'; cursor |
importlabel | Imports a custom label | import alias from '@salesforce/label/label'; cursor |