1
0
Fork 0
mirror of synced 2024-11-17 14:35:34 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/cs.snippets

373 lines
5.5 KiB
Text
Raw Normal View History

#######################################################################
# C# Snippets for UltiSnips #
#######################################################################
priority -50
#########################
# classes and structs #
#########################
snippet namespace "namespace" b
namespace ${1:MyNamespace}
{
${VISUAL}$0
}
endsnippet
snippet class "class" w
2019-05-16 15:48:47 -04:00
${1:public} class ${2:`!p snip.rv = snip.basename`}
{
$0
}
endsnippet
snippet struct "struct" w
2019-05-16 15:48:47 -04:00
struct ${1:`!p snip.rv = snip.basename`}
{
$0
}
endsnippet
snippet interface "interface" w
2019-05-16 15:48:47 -04:00
interface I${1:`!p snip.rv = snip.basename`}
{
$0
}
endsnippet
snippet enum "enumeration" b
enum ${1:MyEnum} { ${2:Item} };
endsnippet
############
# Main() #
############
snippet sim "static int main" b
static int Main(string[] args)
{
$0
}
endsnippet
snippet svm "static void main" b
static void Main(string[] args)
{
$0
}
endsnippet
################
# properties #
################
snippet prop "Simple property declaration" b
public ${1:int} ${2:MyProperty} { get; set; }
endsnippet
snippet propfull "Full property declaration" b
private ${1:int} ${2:_myProperty};
public $1 ${3:MyProperty}
{
get { return $2; }
set { $2 = value; }
}
endsnippet
snippet propg "Property with a private setter" b
public ${1:int} ${2:MyProperty} { get; private set; }
endsnippet
############
# blocks #
############
snippet #if "#if #endif" b
#if ${1:DEBUG}
${VISUAL}$0
#endif
endsnippet
snippet #region "#region #endregion" b
#region ${1:Region}
${VISUAL}$0
#endregion
endsnippet
###########
# loops #
###########
snippet for "for loop" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)
{
${VISUAL}$0
}
endsnippet
snippet forr "for loop (reverse)" b
for (int ${1:i} = ${2:10}; $1 >= 0; $1--)
{
${VISUAL}$0
}
endsnippet
snippet foreach "foreach loop" b
foreach (${3:var} ${2:item} in ${1:items})
{
${VISUAL}$0
}
endsnippet
snippet while "while loop" b
while (${1:true})
{
${VISUAL}$0
}
endsnippet
snippet do "do loop" b
do
{
${VISUAL}$0
} while (${1:true});
endsnippet
###############
# branching #
###############
snippet if "if statement" b
if ($1)
{
${VISUAL}$0
}
endsnippet
snippet ife "if else statement" b
if ($1)
{
${VISUAL}$0
}
else
{
}
endsnippet
snippet elif "else if" b
else if ($1)
{
$0
}
endsnippet
snippet elseif "else if" b
else if ($1)
{
$0
}
endsnippet
snippet ifnn "if not null" b
if ($1 != null)
{
${VISUAL}$0
}
endsnippet
snippet switch "switch statement" b
switch (${1:statement})
{
case ${2:value}:
break;
default:
$0break;
}
endsnippet
snippet case "case" b
case ${1:value}:
$2
break;
endsnippet
##############
# wrappers #
##############
snippet using "using statement" b
using (${1:resource})
{
${VISUAL}$0
}
endsnippet
snippet unchecked "unchecked block" b
unchecked
{
${VISUAL}$0
}
endsnippet
snippet checked "checked block" b
checked
{
${VISUAL}$0
}
endsnippet
snippet unsafe "unsafe" b
unsafe
{
${VISUAL}$0
}
endsnippet
########################
# exception handling #
########################
snippet try "try catch block" b
try
{
${VISUAL}$0
}
catch (${1:Exception} ${2:e})
{
throw;
}
endsnippet
snippet tryf "try finally block" b
try
{
${VISUAL}$0
}
finally
{
}
endsnippet
snippet throw "throw"
2017-02-11 08:01:38 -05:00
throw new $1Exception("$2");
endsnippet
##########
# LINQ #
##########
snippet from "LINQ syntax" b
var ${1:seq} =
from ${2:item1} in ${3:items1}
join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2}
select ${8:$2.prop3}
where ${9:clause}
endsnippet
############################
# feedback and debugging #
############################
snippet da "Debug.Assert" b
Debug.Assert(${1:true});
endsnippet
snippet cw "Console.WriteLine" b
Console.WriteLine("$1");
endsnippet
2017-03-14 11:16:07 -04:00
snippet cr "Console.ReadLine" b
Console.ReadLine();
endsnippet
# as you first type comma-separated parameters on the right, {n} values appear in the format string
snippet cwp "Console.WriteLine with parameters" b
Console.WriteLine("${2:`!p
snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))])
`}"${1:, something});
endsnippet
snippet mbox "Message box" b
MessageBox.Show("${1:message}");
endsnippet
2017-03-14 11:16:07 -04:00
#############
# methods #
#############
snippet equals "Equals method" b
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
$0
return base.Equals(obj);
}
endsnippet
2017-03-14 11:16:07 -04:00
snippet mth "Method" b
${1:public} ${2:void} ${3:MyMethod}(${4})
{
$0
}
endsnippet
snippet mths "Static method" b
${1:public} static ${2:void} ${3:MyMethod}(${4})
{
$0
}
endsnippet
###############
# constructor #
###############
snippet ctor "Constructor" b
${1:public} ${2:`!p snip.rv = snip.basename or "untitled"`}(${3})
{
$0
}
endsnippet
##############
# comments #
##############
2017-03-14 11:16:07 -04:00
snippet /// "XML summary comment" b
/// <summary>
2017-03-14 11:16:07 -04:00
/// $0
/// </summary>
endsnippet
2017-03-14 11:16:07 -04:00
2017-04-01 07:22:06 -04:00
snippet <p "XML pramameter comment" w
2017-03-14 11:16:07 -04:00
<param name="${1}">${2}</param>
endsnippet
2017-04-01 07:22:06 -04:00
snippet <ex "XML exception comment" w
2017-03-14 11:16:07 -04:00
<exception cref="${1:System.Exception}">${2}</exception>
endsnippet
2017-04-01 07:22:06 -04:00
snippet <r "XML returns comment" w
2017-03-14 11:16:07 -04:00
<returns>$0</returns>
endsnippet
2017-04-01 07:22:06 -04:00
snippet <c "XML code comment" w
2017-03-14 11:16:07 -04:00
<code>$0</code>
endsnippet