1
0
Fork 0
mirror of synced 2024-11-30 04:35:35 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/ps1.snippets

103 lines
1.6 KiB
Text
Raw Normal View History

2018-03-31 10:56:26 -04:00
# Snippets for
2016-11-09 12:22:55 -05:00
# Authored by Trevor Sullivan <trevor@trevorsullivan.net>
# PowerShell Class
snippet class
class {
2018-03-31 10:56:26 -04:00
[string] ${1:FirstName}
2016-11-09 12:22:55 -05:00
}
2018-03-31 10:56:26 -04:00
# PowerShell Advanced Function
2016-11-09 12:22:55 -05:00
snippet function
2018-03-31 10:56:26 -04:00
function ${1:name} {
2016-11-09 12:22:55 -05:00
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
2018-03-31 10:56:26 -04:00
[string] ${2:Param}
2016-11-09 12:22:55 -05:00
)
begin {
}
process {
}
end {
}
}
# PowerShell Splatting
snippet splatting
$Params = @{
2018-03-31 10:56:26 -04:00
${1:Param1} = '{2:Value1}'
${3:Param2} = '{4:Value2}'
2016-11-09 12:22:55 -05:00
}
2018-03-31 10:56:26 -04:00
${5:CommandName} @Params
2016-11-09 12:22:55 -05:00
# PowerShell Enumeration
snippet enum
2018-03-31 10:56:26 -04:00
enum ${1:name} {
${2:item1}
${3:item2}
2016-11-09 12:22:55 -05:00
}
# PowerShell if..then
snippet if
2018-03-31 10:56:26 -04:00
if (${1:condition}) {
${2:statement}
}
# PowerShell if..else
snippet ife
if ( ${1:condition} ) {
${2}
}
else {
${3}
2016-11-09 12:22:55 -05:00
}
# PowerShell While Loop
snippet while
2018-03-31 10:56:26 -04:00
while (${1:condition}) {
${2:statement}
2016-11-09 12:22:55 -05:00
}
# PowerShell Filter..Sort
snippet filtersort
2018-03-31 10:56:26 -04:00
${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} }