1
0
Fork 0
mirror of synced 2024-12-21 22:41:06 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/ps1.snippets
Amir Salihefendic 02572caa95 Updated plugins
2018-03-31 11:56:26 -03:00

102 lines
1.6 KiB
Text

# Snippets for
# Authored by Trevor Sullivan <trevor@trevorsullivan.net>
# PowerShell Class
snippet class
class {
[string] ${1:FirstName}
}
# PowerShell Advanced Function
snippet function
function ${1:name} {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] ${2:Param}
)
begin {
}
process {
}
end {
}
}
# PowerShell Splatting
snippet splatting
$Params = @{
${1:Param1} = '{2:Value1}'
${3:Param2} = '{4:Value2}'
}
${5:CommandName} @Params
# PowerShell Enumeration
snippet enum
enum ${1:name} {
${2:item1}
${3:item2}
}
# PowerShell if..then
snippet if
if (${1:condition}) {
${2:statement}
}
# PowerShell if..else
snippet ife
if ( ${1:condition} ) {
${2}
}
else {
${3}
}
# PowerShell While Loop
snippet while
while (${1:condition}) {
${2:statement}
}
# PowerShell Filter..Sort
snippet filtersort
${1:command} | Where-Object -FilterScript { $PSItem.${2:property} -${3:operator} '${4:expression}' } | Sort-Object -Property ${5:sortproperty}
# PowerShell foreach
snippet foreach
foreach ( $${1:iterator} in $${2:collection} ) {
${3:statement}
}
# PowerShell export-csv
snippet epcsv
Export-CSV -NoTypeInformation -Path ${1:path}
# Powershell Comment Based Help
snippet help
<#
.SYNOPSIS
${1:Short Description}
.DESCRIPTION
${2:Full Description}
.PARAMETER ${3:Param1}
${4: $3 usage}
.EXAMPLE
${5:Example}
.NOTES
${6:notes}
.LINK
${7:online help}
#>
# Powershell switch statement
snippet switch
switch ( ${1:test} ){
${2:condition1} { ${3:action} }
${4:condition2} { ${5:action} }
default { ${6:action} }