Small fixes and new c-sharp (cs) snippets by Matthew Strawbridge.

This commit is contained in:
Holger Rapp 2013-04-15 07:19:07 +02:00
parent e10285b382
commit 997294adc5
7 changed files with 365 additions and 34 deletions

View File

@ -6,7 +6,7 @@ with the official bzr repository over at Launchpad [1] and is meant as a
convenience for contributors. Send Pull request to this repository, not
the automatic clone from vim-scripts.
Note that we do not use the Issue tracker here one GitHub because the one on
Note that we do not use the Issue tracker here on GitHub because the one on
Launchpad is superior and already has a significant history. Please report
`issues over there`_.

328
UltiSnips/cs.snippets Normal file
View File

@ -0,0 +1,328 @@
#######################################################################
# C# Snippets for UltiSnips #
#######################################################################
#########################
# classes and structs #
#########################
snippet namespace "namespace" b
namespace ${1:MyNamespace}
{
${VISUAL}$0
}
endsnippet
snippet class "class" w
class ${1:MyClass}
{
$0
}
endsnippet
snippet struct "struct" w
struct ${1:MyStruct}
{
$0
}
endsnippet
snippet interface "interface" w
interface I${1:Interface}
{
$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"
throw new ${1}Exception("${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
# 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
##################
# full 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
##############
# comments #
##############
snippet /// "XML comment" b
/// <summary>
/// $1
/// </summary>
endsnippet

View File

@ -7,7 +7,7 @@
# before '{' braces.
# Setting "g:ultisnips_java_junit" will change how the test method snippet
# looks, it is defaulted to junit4, setting this option to 3 will remove the
# @Test annotation from the method
# @Test annotation from the method
global !p
def junit(snip):
@ -126,7 +126,7 @@ for i in args:
}
endsnippet
snippet clc "class with constucutor, with field names" b
snippet clc "class with constructor, with field names" b
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
@ -145,7 +145,7 @@ if len(args) == 0:
}
endsnippet
snippet clc "class and constrcutor" b
snippet clc "class and constructor" b
public class `!p
snip.rv = snip.basename or "untitled"` {
@ -230,7 +230,7 @@ interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent
}
endsnippet
snippet cc "constuctor call or setter body"
snippet cc "constructor call or setter body"
this.${1:var} = $1;
endsnippet

View File

@ -193,7 +193,6 @@ function ${1:name}(${2:$param})
}
$0
endsnippet
# :vim:ft=snippets
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}){
@ -207,7 +206,6 @@ $$1 = new $1($2);
$0
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
@ -217,7 +215,6 @@ if (${1:/* condition */}) {
$0
endsnippet
snippet class "Class declaration template" !b
/**
* Class ${1:`!p snip.rv=snip.fn.capitalize().split('.')[0]`}

View File

@ -53,7 +53,7 @@ snippet desc "Description" b
endsnippet
#####################################
# SECTIONS, CHAPTERS AND THERE LIKE #
# SECTIONS, CHAPTERS AND THEIR LIKE #
#####################################
snippet part "Part" b

View File

@ -1,3 +1,8 @@
snippet xml "XML declaration" b
<?xml version="1.0"?>
endsnippet
snippet t "Simple tag" b
<${1:tag}>
${2:content}

View File

@ -87,18 +87,18 @@ They print '1' if the python version is compiled in, '0' if not.
Test if Vim is compiled with python version 2.x: >
:echo has("python")
The python version Vim is linked agains can be found with: >
The python version Vim is linked against can be found with: >
:py import sys; print(sys.version)
Test if Vim is compiled with python version 3.x: >
:echo has("python3")
The python version Vim is linked agains can be found with: >
The python version Vim is linked against can be found with: >
:py3 import sys; print(sys.version)
Note that Vim is maybe not using your system wide installed python version, so
Note that Vim is maybe not using your system-wide installed python version, so
make sure to check the Python version inside of Vim.
UltiSnips attempts to autodetect which python version is compiled into Vim.
UltiSnips attempts to auto-detect which python version is compiled into Vim.
Unfortunately, in some versions of Vim this detection does not work.
In that case you have to explicitly tell UltiSnips which version to use using
the 'UltiSnipsUsePythonVersion' global variable.
@ -175,14 +175,14 @@ to runtimepath. See |UltiSnips-using-bzr| for an example.
------------
*:UltiSnipsEdit*
The UltiSnipsEdit command opens the private snippet definition file for the
current filetype for editing. If a definition file does not exist a new file
current filetype for editing. If a definition file does not exist, a new file
is opened with the appropriate name. Snippet definition files are standard
text files and can be edited directly. UltiSnipsEdit makes it easier.
There are several variables associated with the UltiSnipsEdit command.
*g:UltiSnipsEditSplit*
g:UltiSnipsEditSplit Defines how the edit window is open. Possible
g:UltiSnipsEditSplit Defines how the edit window is opened. Possible
values:
|normal| Default. Opens in the current window.
|horizontal| Splits the window horizontally.
@ -198,7 +198,7 @@ g:UltiSnipsSnippetsDir
*:UltiSnipsAddFiletypes*
The UltiSnipsAddFiletypes command allows for explicit merging of other snippet
filetypes for the current buffer. For example if you edit a .rst file, but
filetypes for the current buffer. For example, if you edit a .rst file but
also want the Lua snippets to be available you can issue the command >
:UltiSnipsAddFiletypes rst.lua
@ -210,8 +210,8 @@ ftplugin/rails.vim >
:UltiSnipsAddFiletypes rails.ruby
I mention rails first, because I want to edit rails snippet when using
UltiSnipsEdit and because rails snippet should overwrite equivalent ruby
I mention rails first because I want to edit rails snippets when using
UltiSnipsEdit and because rails snippets should overwrite equivalent ruby
snippets. The priority will now be rails -> ruby -> all. If you have some
special programming snippets that should have lower priority than your ruby
snippets you can call >
@ -249,13 +249,13 @@ key and that correspond to some of the triggers previously defined:
g:UltiSnipsJumpBackwardTrigger <--> UltiSnips_JumpBackwards
If you have g:UltiSnipsExpandTrigger and g:UltiSnipsJumpForwardTrigger set
to the same value then when the function you are actually going to use is
to the same value then the function you are actually going to use is
UltiSnips_ExpandSnippetOrJump.
Each time any of the functions UltiSnips_ExpandSnippet,
UltiSnips_ExpandSnippet, UltiSnips_JumpBackwards or UltiSnips_JumpBackwards is
called a global variable is set that contains the corresponding return value
of the corresponding function.
called a global variable is set that contains the return value of the
corresponding function.
The corresponding variables and functions are:
UltiSnips_ExpandSnippet --> g:ulti_expand_res (0: fail, 1: success)
@ -264,10 +264,10 @@ UltiSnips_ExpandSnippetOrJump --> g:ulti_expand_or_jump_res (0: fail,
UltiSnips_JumpForwards --> g:ulti_jump_forwards_res (0: fail, 1: success)
UltiSnips_JumpBackwards --> g:ulti_jump_backwards_res (0: fail, 1: success)
To see how these return values may come in handy suppose that you want to map
To see how these return values may come in handy, suppose that you want to map
a key to expand or jump, but if none of these actions is successful you want
to call another function. Ultisnips already does this automatically for
supertab, but this allows you individual fine tuning of your tab key usage.
to call another function. UltiSnips already does this automatically for
supertab, but this allows you individual fine tuning of your Tab key usage.
Usage is as follows: You define a function >
@ -310,8 +310,8 @@ Here is a small example funtion that expands a snippet: >
-----------------------
UltiSnips snippet definition files are stored in one or more directories.
There are several variables used to indicate those directories and define how
UltiSnips loads snippets.
There are several variables used to indicate those directories and to define
how UltiSnips loads snippets.
Snippet definition files are stored in snippet directories. A snippet
directory must be a subdirectory of a directory defined in the 'runtimepath'
@ -406,7 +406,7 @@ An example use case might be this line from a reStructuredText plugin file:
inoremap <silent> $$ $$<C-R>=UltiSnips_Anon(':latex:\`$1\`', '$$')<cr>
This expands the snippet whenever two $ signs are typed.
Note: The right hand side of the mapping starts with an immediate retype of
Note: The right-hand side of the mapping starts with an immediate retype of
the '$$' trigger and passes '$$' to the function as the trigger argument.
This is required in order for UltiSnips to have access to the characters
typed so it can determine if the trigger matches or not.
@ -459,7 +459,7 @@ snippet filenames and their associated filetype.
* The 'all' filetype is unique. It represents snippets available for use when
editing any document regardless of the filetype. A date insertion snippet, for
example, would be fit well in the all.snippets file.
example, would fit well in the all.snippets file.
UltiSnips understands Vim's dotted filetype syntax. For example, if you define
a dotted filetype for the CUDA C++ framework, e.g. ":set ft=cuda.cpp", then
@ -731,7 +731,7 @@ endsnippet
4.4.3 Python: *UltiSnips-python*
By far python interpolation is the most powerful. The syntax is similar to Vim
Python interpolation is by far the most powerful. The syntax is similar to Vim
scripts except code is started with '!p'. Python scripts can be run using the
python shebang '#!/usr/bin/python', but using the '!p' format comes with some
predefined objects and variables, which can simplify and shorten code. For
@ -849,7 +849,7 @@ be center<tab> ->
\end{center}
The second form is a variation of the first, both produce the same result,
The second form is a variation of the first; both produce the same result,
but it illustrates how regular expression grouping works. Using regular
expressions in this manner has some drawbacks:
1. If you use the <Tab> key for both expanding snippets and completion then
@ -1117,7 +1117,7 @@ The replacement string can contain $no variables, e.g., $1, which reference
matched groups in the regular expression. The $0 variable is special and
yields the whole match. The replacement string can also contain special escape
sequences: >
\u - Uppercase next letter;
\u - Uppercase next letter
\l - Lowercase next letter
\U - Uppercase everything till the next \E
\L - Lowercase everything till the next \E
@ -1216,12 +1216,12 @@ snippets if you wish to replace them. Simply use the '!' option. (See
==============================================================================
5. Support for other plugins *UltiSnips-other-plugins*
Ultisnips has build in support for some common plugins and there are others
UltiSnips has built-in support for some common plugins and there are others
that are aware of UltiSnips and use it to improve the user experience. This is
an incomplete list - if you want to have your plugin listed here, just sent me
a pull request.
Supertab - UltiSnips has build in support for Supertab. Just use a recent
Supertab - UltiSnips has built-in support for Supertab. Just use a recent
enough version of both plugins and <tab> will either expand a snippet or defer
to Supertab for expansion.
@ -1256,7 +1256,7 @@ https://bugs.launchpad.net/ultisnips
If you like this plugin, please vote for it on its Vim script page >
http://www.vim.org/scripts/script.php?script_id=2715
It is life changing for me. Maybe it is for you too.
It is life-changing for me. Maybe it is for you too.
=============================================================================
@ -1360,6 +1360,7 @@ Contributors listed in chronological order:
Vangelis Tsoumenis (kioopi)
Rudi Grinberg (rgrinberg)
javipolo
Matthew Strawbridge (pxc)
Thank you for your support.