/usr/share/vim/addons/snippets/c.snippets is in vim-snippets 1.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | ## Main
# main
snippet main
int main(int argc, const char *argv[])
{
${0}
return 0;
}
# main(void)
snippet mainn
int main(void)
{
${0}
return 0;
}
##
## Preprocessor
# #include <...>
snippet inc
#include <${1:stdio}.h>
# #include "..."
snippet Inc
#include "${1:`vim_snippets#Filename("$1.h")`}"
# ifndef...define...endif
snippet ndef
#ifndef $1
#define ${1:SYMBOL} ${2:value}
#endif
# define
snippet def
#define
# ifdef...endif
snippet ifdef
#ifdef ${1:FOO}
${2:#define }
#endif
# if
snippet #if
#if ${1:FOO}
${0}
#endif
# header include guard
snippet once
#ifndef ${1:`toupper(vim_snippets#Filename('$1_H', 'UNTITLED_H'))`}
#define $1
${0}
#endif /* end of include guard: $1 */
##
## Control Statements
# if
snippet if
if (${1:/* condition */}) {
${2}
}
# else
snippet el
else {
${1}
}
# else if
snippet elif
else if (${1:/* condition */}) {
${2}
}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};
# ternary
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}
# switch
snippet switch
switch (${1:/* variable */}) {
case ${2:/* variable case */}:
${3}
${4:break;}${5}
default:
${6}
}
# switch without default
snippet switchndef
switch (${1:/* variable */}) {
case ${2:/* variable case */}:
${3}
${4:break;}${5}
}
# case
snippet case
case ${1:/* variable case */}:
${2}
${3:break;}
##
## Loops
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
snippet wh
while (${1:/* condition */}) {
${2}
}
# do... while
snippet do
do {
${2}
} while (${1:/* condition */});
##
## Functions
# function definition
snippet fun
${1:void} ${2:function_name}(${3})
{
${4}
}
# function declaration
snippet fund
${1:void} ${2:function_name}(${3});
##
## Types
# typedef
snippet td
typedef ${1:int} ${2:MyCustomType};
# struct
snippet st
struct ${1:`vim_snippets#Filename('$1_t', 'name')`} {
${2:/* data */}
}${3: /* optional variable list */};
# typedef struct
snippet tds
typedef struct ${2:_$1 }{
${3:/* data */}
} ${1:`vim_snippets#Filename('$1_t', 'name')`};
# typedef enum
snippet tde
typedef enum {
${1:/* data */}
} ${2:foo};
##
## Input/Output
# printf
snippet pr
printf("${1:%s}\n"${2});
# fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});
# getopt
snippet getopt
int choice;
while (1)
{
static struct option long_options[] =
{
/* Use flags like so:
{"verbose", no_argument, &verbose_flag, 'V'}*/
/* Argument styles: no_argument, required_argument, optional_argument */
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
${1}
{0,0,0,0}
};
int option_index = 0;
/* Argument parameters:
no_argument: " "
required_argument: ":"
optional_argument: "::" */
choice = getopt_long( argc, argv, "vh",
long_options, &option_index);
if (choice == -1)
break;
switch( choice )
{
case 'v':
${2}
break;
case 'h':
${3}
break;
case '?':
/* getopt_long will have already printed an error */
break;
default:
/* Not sure how to get here... */
return EXIT_FAILURE;
}
}
/* Deal with non-option arguments here */
if ( optind < argc )
{
while ( optind < argc )
{
${0}
}
}
##
## Miscellaneous
# This is kind of convenient
snippet .
[${1}]
# GPL
snippet gpl
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) ${1:Author}, `strftime("%Y")`
*/
${0}
|