1
0
Fork 0
mirror of synced 2024-12-29 01:53:21 -05:00
ultimate-vim/sources_non_forked_fallback/vim-snippets/snippets/ps1.snippets

102 lines
1.5 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 = @{
2020-12-04 16:15:32 -05: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
if ($1) {
$0
2018-03-31 10:56:26 -04:00
}
# PowerShell if..else
snippet ife
if ( $1 ) {
2018-03-31 10:56:26 -04:00
${2}
}
else {
${3}
2016-11-09 12:22:55 -05:00
}
# PowerShell While Loop
snippet while
while ($1) {
$0
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} ) {
$0
2018-03-31 10:56:26 -04:00
}
# 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} }