Skip to content
Browse files

Make function snippets more sensible

- The snippet for a short function now actually outputs short boilerplate without useless cruft, and the tab trigger for the short function is short.
- The snippet for the full function boilerplate that you would put at the top of a file matches MATLAB's documentation-in-comments a bit better, but not perfectly, because if we all emulated MATLAB perfectly the world would explode, and it's more important to be able to read the comments in the source code than for MATLAB to be able to read the comments in the source code. Also the tab trigger is longer, as is proper. Also got rid of stupid copyright cruft.
  • Loading branch information...
1 parent b10394f commit 802ec43b0e5105910800aa147f7ae965692cd29e Daniel Grady committed with infininight Nov 3, 2010
Showing with 20 additions and 15 deletions.
  1. +9 −11 Snippets/function (fun).plist
  2. +11 −4 Snippets/small function.tmSnippet
20 Snippets/function (fun).plist
@@ -3,14 +3,11 @@
<plist version="1.0">
- <string>function ${1:Output variables} = ${2:functionName}(${3:Input variables})
-$TM_COMMENT_START ${2/.*/\U$0/} ${4:Short description}
-$TM_COMMENT_START [${1/.*/\U$0/}] = ${2/.*/\U$0/}(${6:${3/.*/\U$0/}})
-$TM_COMMENT_START ${5:Long description}
-$TM_COMMENT_START Created by $TM_FULLNAME on `date +%Y-%m-%d`.
-$TM_COMMENT_START Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+ <string>function ${1:out} = ${2:f}(${3:in})
+% ${2/.*/\U$0/} ${4:Description}
+% ${1/.*/\U$0/} = ${2/.*/\U$0/}(${6:${3/.*/\U$0/}})
+% ${5:Long description}
@@ -19,15 +16,16 @@ $0
if [[ $TM_USE_OCTAVE -ne '0' ]]
then echo "endfunction"
- echo "end $TM_COMMENT_START function"
+ echo "end ${TM_COMMENT_START}function"
<string>source.matlab, source.octave</string>
- <string>fun</string>
+ <string>function</string>
15 Snippets/small function.tmSnippet
@@ -3,15 +3,22 @@
<plist version="1.0">
- <string>%% ${1:functionname}: ${2:function description}
-function [${3:outputs}] = ${1}(${4:arg})
-${3/,?\s*([a-zA-Z]\w*)|,\s*/(?1:\t$1 = ;\n)/g}</string>
+ <string>function ${1:out} = ${2:f}(${3:in})
+ $0
+`if [[ $TM_CLOSE_FUNCTIONS -ne '0' ]]
+ then
+ if [[ $TM_USE_OCTAVE -ne '0' ]]
+ then echo "endfunction"
+ else
+ echo "end"
+ fi
<string>small function</string>
<string>source.matlab, source.octave</string>
- <string>func</string>
+ <string>f</string>

0 comments on commit 802ec43

Please sign in to comment.
Something went wrong with that request. Please try again.