1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-20 04:47:59 +01:00

added saner default snippets

This commit is contained in:
msanders
2009-12-27 22:07:47 -05:00
parent 656262896f
commit 1b261234b2
3 changed files with 26 additions and 35 deletions

View File

@@ -5,3 +5,5 @@ snippet c)
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
snippet date snippet date
`strftime("%Y-%m-%d")` `strftime("%Y-%m-%d")`
snippet ddate
`strftime("%B %d, %Y")`

View File

@@ -5,6 +5,12 @@ snippet main
${1} ${1}
return 0; return 0;
} }
snippet mainn
int main(void)
{
${1}
return 0;
}
# #include <...> # #include <...>
snippet inc snippet inc
#include <${1:stdio}.h>${2} #include <${1:stdio}.h>${2}
@@ -17,7 +23,7 @@ snippet Def
#define ${1:SYMBOL} ${2:value} #define ${1:SYMBOL} ${2:value}
#endif${3} #endif${3}
snippet def snippet def
#define #define
snippet ifdef snippet ifdef
#ifdef ${1:FOO} #ifdef ${1:FOO}
${2:#define } ${2:#define }
@@ -27,10 +33,8 @@ snippet #if
${2} ${2}
#endif #endif
# Header Include-Guard # Header Include-Guard
# (the randomizer code is taken directly from TextMate; it could probably be
# cleaner, I don't know how to do it in vim script)
snippet once snippet once
#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/env ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`} #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
#define $1 #define $1
@@ -104,7 +108,6 @@ snippet pr
# fprintf (again, this isn't as nice as TextMate's version, but it works) # fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});${4} fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
# This is kind of convenient
snippet . snippet .
[${1}]${2} [${1}]${2}
snippet un
unsigned

View File

@@ -38,22 +38,26 @@ snippet impl
@implementation ${1:`Filename('', 'someClass')`} @implementation ${1:`Filename('', 'someClass')`}
${2} ${2}
@end @end
# Protocol
snippet pro
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${3}
@end
snippet init snippet init
- (id)init - (id)init
{ {
[super init]; if (self = [super init]) {
${1}
}
return self; return self;
} }
snippet ifself snippet su
if (self = [super init]) { [super ${1:init}]${2}
${1:/* code */}
}
return self;
snippet ibo snippet ibo
IBOutlet ${1:NSSomeClass} *${2:$1};${3} IBOutlet ${1:NSSomeClass} *${2:$1};${3}
# Category # Category
snippet cat snippet cat
@interface ${1:NSObject} (${2:Category}) @interface ${1:NSObject} (${2:MyCategory})
@end @end
@implementation $1 ($2) @implementation $1 ($2)
@@ -61,18 +65,9 @@ snippet cat
@end @end
# Category Interface # Category Interface
snippet cath snippet cath
@interface ${1:NSObject} (${2:Category}) @interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory})
${3} ${3}
@end @end
# NSArray
snippet array
NSMutableArray *${1:array} = [NSMutable array];${2}
# NSDictionary
snippet dict
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
# NSBezierPath
snippet bez
NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}
# Method # Method
snippet m snippet m
- (${1:id})${2:method} - (${1:id})${2:method}
@@ -100,8 +95,8 @@ snippet wake
# Class Method # Class Method
snippet M snippet M
+ (${1:id})${2:method} + (${1:id})${2:method}
{${3} {
return nil; ${3:return nil;}
} }
# Sub-method (Call super) # Sub-method (Call super)
snippet sm snippet sm
@@ -110,14 +105,6 @@ snippet sm
[super $2];${3} [super $2];${3}
return self; return self;
} }
# Method: Initialize
snippet I
+ (void) initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:
${1}@"value", @"key",
nil]];
}
# Accessor Methods For: # Accessor Methods For:
# Object # Object
snippet objacc snippet objacc
@@ -160,7 +147,6 @@ snippet ret
# release # release
snippet rel snippet rel
[${1:foo} release]; [${1:foo} release];
${2:$1 = nil;}
# autorelease # autorelease
snippet arel snippet arel
[${1:foo} autorelease]; [${1:foo} autorelease];
@@ -177,7 +163,7 @@ snippet except
userInfo:nil]; userInfo:nil];
[$1 raise]; [$1 raise];
snippet prag snippet prag
#pragma mark ${1:foo} #pragma mark ${1:-}
snippet cl snippet cl
@class ${1:Foo};${2} @class ${1:Foo};${2}
snippet color snippet color