mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Tweaking the TextMate C snippets
This commit is contained in:
parent
c323cddbd6
commit
f5aaad220f
@ -1,8 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: def
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: #ifndef … #define … #endif
|
||||
# --
|
||||
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
|
||||
#define ${1:SYMBOL} ${2:value}
|
||||
#endif
|
||||
${1:$(if (string= text "") "" (concat "#ifndef " text "\n"))}#define ${1:SYMBOL} ${2:value}${1:$(if (string= text "") "" (concat "\n#endif "))}
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: for
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: For Loop
|
||||
# expand-env: ((yas/wrap-around-region t))
|
||||
# --
|
||||
for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++i$(unless yas/modified-p (concat "++" (yas/field-value 2)))})
|
||||
{
|
||||
${0:/* code */}
|
||||
$0
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fprintf
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: fprintf …
|
||||
# name: fprintf (...)
|
||||
# --
|
||||
fprintf(${1:stderr}, "${2:%s}\\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
||||
fprintf (${1:stderr}, "${2:%s}\\n"${2:$(if (string-match "%[^%]" text) "," "\);")}$3${2:$(if (string-match "%" text) "\);" "")}
|
9
extras/imported/c-mode/once with #ifndef.yasnippet
Normal file
9
extras/imported/c-mode/once with #ifndef.yasnippet
Normal file
@ -0,0 +1,9 @@
|
||||
# key:once
|
||||
# name : #ifndef XXX; #define XXX; #endif
|
||||
# --
|
||||
#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (or (buffer-file-name) (buffer-name)))))`_H_}
|
||||
#define $1
|
||||
|
||||
$0
|
||||
|
||||
#endif /* $1 */
|
@ -1,6 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: printf
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: printf …
|
||||
# name: printf (...)
|
||||
# --
|
||||
printf("${1:%s}\\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
||||
printf ("${1:%s}\\n"${1:$(if (string-match "%[^%]" text) "," "\);")
|
||||
}$2${1:$(if (string-match "%" text) "\);" "")}
|
||||
|
5
extras/imported/c-mode/snprintf.yasnippet
Normal file
5
extras/imported/c-mode/snprintf.yasnippet
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: sprintf
|
||||
# name: s(n)printf …
|
||||
# --
|
||||
s${2:$(if (string= text "") "" "n")}printf (${1:string}${2:$(if (string= text "") "" ",")}${2:size}, "${3:%s}\\n"${3:$(if (string-match "%[^%]" text) "," "\);")}$4${3:$(if (string-match "%" text) "\);" "")}
|
@ -3,6 +3,6 @@
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Insert do |variable| … end
|
||||
# --
|
||||
do${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${1:variable}${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/}
|
||||
$0
|
||||
do ${1:$(if (string= yas/text "") "" "|")}${1:variable}${1:$(if (string= yas/text "") "" "|")}
|
||||
$0
|
||||
end
|
@ -2,5 +2,6 @@
|
||||
# key: lam
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: lambda { |args| .. }
|
||||
# expand-env: ((yas/wrap-around-region t))
|
||||
# --
|
||||
lambda { ${1/(^(?<var>\s*(?:\*|\*?[a-z_])[a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/}${1:args}${1/(^(?<var>\s*(?:\*|\*?[a-z_])[a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:| )/}$0 }
|
||||
lambda { ${1:$(if (string= yas/text "") "" "|")}${1:variable}${1:$(if (string= yas/text "") "" "|")} $0 }
|
@ -2,5 +2,6 @@
|
||||
# key: {
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Insert { |variable| … }
|
||||
# expand-env: ((yas/wrap-around-region t))
|
||||
# --
|
||||
{ ${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/}${1:variable}${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:| )/}${2:`yas/selected-text`}
|
||||
{ ${1:$(if (string= yas/text "") "" "|")}${1:variable}${1:$(if (string= yas/text "") "" "|")} $0 }
|
@ -2,5 +2,6 @@
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Insert ERb’s <% .. %> or <%= .. %>
|
||||
# binding: "^>"
|
||||
# expand-env: ((yas/wrap-around-region t))
|
||||
# --
|
||||
<%= `yas/selected-text`$0 %>
|
||||
<%= $0 %>
|
Loading…
x
Reference in New Issue
Block a user