diff --git a/after/ftplugin/c_snips.vim b/after/ftplugin/c_snips.vim
index d6bf59e..78a3659 100644
--- a/after/ftplugin/c_snips.vim
+++ b/after/ftplugin/c_snips.vim
@@ -1,7 +1,9 @@
-if !exists('loaded_snips') || exists('s:did_'.&ft.'_snips')
+if !exists('loaded_snips') || exists('s:did_c_snips')
fini
en
-let s:did_{&ft}_snips = 1
+let s:did_c_snips = 1
+let ft = &ft
+let &ft ='c'
" main()
exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
@@ -29,7 +31,7 @@ exe "Snipp do do {\n\t${2:/* code */}\n} while (${1:/* condition */});"
" While Loop
exe "Snipp wh while (${1:/* condition */}) {\n\t${2:/* code */}\n}"
" For Loop
-exe "Snipp for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\t${4:/* code */}\n}"
+exe "Snipp for for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\t${4:/* code */}\n}${5}"
" Custom For Loop
exe "Snipp forr for (${1:i} = 0; ${2:$1 < 5}; $1${3:++}) {\n\t${4:/* code */}\n}"
" Function
@@ -54,3 +56,4 @@ exe "Snipp vector std::vector<${1:char}> v${2};"
exe 'Snipp pr printf("${1:%s}\n"${2});${3}'
" fprintf (again, this isn't as nice as TextMate's version, but it works)
exe 'Snipp fpr fprintf(${1:stderr}, "${2:%s}\n"${3});${4}'
+let &ft = ft
diff --git a/after/ftplugin/html_snips.vim b/after/ftplugin/html_snips.vim
index e04a3f5..0ff2449 100644
--- a/after/ftplugin/html_snips.vim
+++ b/after/ftplugin/html_snips.vim
@@ -1,10 +1,13 @@
-if !exists('g:loaded_snips') || exists('s:did_'.&ft.'_snips')
+let filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html'
+if !exists('g:loaded_snips') || exists('s:did_'.filetype.'_snips')
fini
en
-let s:did_{&ft}_snips = 1
+let s:did_{filetype}_snips = 1
+let ft = &ft
+let &ft = filetype
" automatically add a closing '/' to the end of xhtml tags
-let c = &ft == 'xhtml' ? ' /' : ''
+let c = filetype == 'xhtml' ? ' /' : ''
" Some useful Unicode entities
" Non-Breaking Space
@@ -92,3 +95,4 @@ exe 'Snipp optt ${2}'
exe "Snipp select ${5}"
exe "Snipp table
\n\t| ${2:Header} |
\n\t| ${3:Data} |
\n
${4}"
exe 'Snipp textarea ${5}'
+let &ft = ft
diff --git a/after/ftplugin/java_snips.vim b/after/ftplugin/java_snips.vim
index adda47a..8cb6402 100644
--- a/after/ftplugin/java_snips.vim
+++ b/after/ftplugin/java_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_java_snips')
fini
en
let s:did_java_snips = 1
+let ft = &ft
+let &ft ='java'
exe "Snipp main public static void main (String [] args)\n{\n\t${1:/* code */}\n}"
exe 'Snipp pu public'
@@ -39,3 +41,5 @@ exe 'Snipp v ${1:String} ${2:var}${3: = null}${4};${5}'
exe 'Snipp co static public final ${1:String} ${2:var} = ${3};${4}'
exe 'Snipp cos static public final String ${1:var} = "${2}";${3}'
exe 'Snipp as assert ${1:test} : "${2:Failure message}";${3}'
+
+let &ft = ft
diff --git a/after/ftplugin/javascript_snips.vim b/after/ftplugin/javascript_snips.vim
index d273791..d28a807 100644
--- a/after/ftplugin/javascript_snips.vim
+++ b/after/ftplugin/javascript_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_js_snips')
fini
en
let s:did_js_snips = 1
+let ft = &ft
+let &ft ='javascript'
" Prototype
exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"
@@ -35,3 +37,5 @@ exe 'Snipp timeout setTimeout(function() {${3}}${2}, ${1:10};'
exe "Snipp get getElementsBy${1:TagName}('${2}')${3}"
" Get Element
exe "Snipp gett getElementBy${1:Id}('${2}')${3}"
+
+let &ft = ft
diff --git a/after/ftplugin/objc_snips.vim b/after/ftplugin/objc_snips.vim
index 6a04b71..edefa2e 100644
--- a/after/ftplugin/objc_snips.vim
+++ b/after/ftplugin/objc_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_objc_snips')
fini
en
let s:did_objc_snips = 1
+let ft = &ft
+let &ft ='objc'
" #import <...>
exe 'Snipp imp #import <${1:Cocoa/Cocoa.h}>${2}'
@@ -52,3 +54,5 @@ exe 'Snipp alloc [[${1:foo} alloc] init]${2};${3}'
exe 'Snipp ret [${1:foo} retain];${2}'
" release
exe 'Snipp rel [${1:foo} release];${2}'
+
+let &ft = ft
diff --git a/after/ftplugin/perl_snips.vim b/after/ftplugin/perl_snips.vim
index 1a0e230..413034a 100644
--- a/after/ftplugin/perl_snips.vim
+++ b/after/ftplugin/perl_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_perl_snips')
fini
en
let s:did_perl_snips = 1
+let ft = &ft
+let &ft ='perl'
" Hash Pointer
exe 'Snipp . =>'
@@ -35,3 +37,5 @@ exe 'Snipp xfore ${1:expression} foreach @${2:array};${3}'
exe "Snipp cl package ${1:ClassName};\n\nuse base qw(${2:ParentClass});\n\nsub new {\n\tmy $class = shift;\n\t$class = ref $class if ref $class;\n\tmy $self = bless {}, $class;\n\t$self;\n}\n\n1;${3}"
" Read File
exe "Snipp slurp my $${1:var};\n{ local $/ = undef; local *FILE; open FILE, \"<${2:file}\"; $$1 = ; close FILE }${2}"
+
+let &ft = ft
diff --git a/after/ftplugin/php_snips.vim b/after/ftplugin/php_snips.vim
index 7a87720..69f7ff5 100644
--- a/after/ftplugin/php_snips.vim
+++ b/after/ftplugin/php_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_php_snips')
fini
en
let s:did_php_snips = 1
+let ft = &ft
+let &ft ='php'
exe "Snipp php "
exe 'Snipp ec echo "${1:string}"${2};'
@@ -65,3 +67,4 @@ exe "Snipp foreach foreach ($${1:variable} as $${2:key}) {\n\t${3:// code...}\n}
exe "Snipp fun ${1:public }function ${2:FunctionName}(${3})\n{\n\t${4:// code...}\n}"
" $... = array (...)
exe "Snipp array $${1:arrayName} = array('${2}' => ${3});${4}"
+let &ft = ft
diff --git a/after/ftplugin/python_snips.vim b/after/ftplugin/python_snips.vim
index e663039..eb4e9e0 100644
--- a/after/ftplugin/python_snips.vim
+++ b/after/ftplugin/python_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_python_snips')
fini
en
let s:did_python_snips = 1
+let ft = &ft
+let &ft ='python'
" New Class
exe "Snipp cl class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.$4 = $4\n\t\t${6}"
@@ -26,3 +28,5 @@ exe "Snipp tryef try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise
exe "Snipp ifmain if __name__ == '__main__':\n\t${1:main()}"
" __magic__
exe 'Snipp _ __${1:init}__${2}'
+
+let &ft = ft
diff --git a/after/ftplugin/ruby_snips.vim b/after/ftplugin/ruby_snips.vim
index de16c6e..374c65b 100644
--- a/after/ftplugin/ruby_snips.vim
+++ b/after/ftplugin/ruby_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_ruby_snips')
fini
en
let s:did_ruby_snips = 1
+let ft = &ft
+let &ft ='ruby'
" New Block
exe "Snipp =b =begin rdoc\n\t${1}\n=end"
@@ -165,3 +167,4 @@ exe 'Snipp clafn split("::").inject(Object) { |par, const| par.const_get(const)
exe 'Snipp sinc class << self; self end'
exe "Snipp nam namespace :${1:`Filename()`} do\n\t${2}\nend"
exe "Snipp tas desc \"${1:Task description\}\"\ntask :${2:task_name => [:dependent, :tasks]} do\n\t${3}\nend"
+let &ft = ft
diff --git a/after/ftplugin/sh_snips.vim b/after/ftplugin/sh_snips.vim
index a7794da..b5f498b 100644
--- a/after/ftplugin/sh_snips.vim
+++ b/after/ftplugin/sh_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_sh_snips')
fini
en
let s:did_sh_snips = 1
+let ft = &ft
+let &ft = 'sh'
exe "Snipp if if [[ ${1:condition} ]]; then\n\t${2:#statements}\nfi"
exe "Snipp elif elif [[ ${1:condition} ]]; then\n\t${2:#statements}"
@@ -9,3 +11,5 @@ exe "Snipp for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\t${3:#statement
exe "Snipp wh while [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
exe "Snipp until [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
exe "Snipp case case ${1:word} in\n\t${2:pattern})\n\t\t${3};;\nesac"
+
+let &ft = ft
diff --git a/after/ftplugin/tex_snips.vim b/after/ftplugin/tex_snips.vim
index b912802..aa0d6c2 100644
--- a/after/ftplugin/tex_snips.vim
+++ b/after/ftplugin/tex_snips.vim
@@ -2,6 +2,8 @@ if !exists('loaded_snips') || exists('s:did_tex_snips')
fini
en
let s:did_tex_snips = 1
+let ft = &ft
+let &ft = 'tex'
" \begin{}...\end{}
exe "Snipp begin \\begin{${1:env}}\n\t${2}\n\\end{$1}"
@@ -47,3 +49,5 @@ exe 'Snipp table ${1:Table}~\ref{${2:tab:}}${3}'
exe 'Snipp listing ${1:Listing}~\ref{${2:list}}${3}'
exe 'Snipp section ${1:Section}~\ref{${2:sec:}}${3}'
exe 'Snipp page ${1:page}~\pageref{${2}}${3}'
+
+let &ft = ft
diff --git a/after/ftplugin/vim_snips.vim b/after/ftplugin/vim_snips.vim
index e5b4c9c..459a152 100644
--- a/after/ftplugin/vim_snips.vim
+++ b/after/ftplugin/vim_snips.vim
@@ -2,6 +2,8 @@ if !exists('g:loaded_snips') || exists('s:did_vim_snips')
fini
en
let s:did_vim_snips = 1
+let ft = &ft
+let &ft = 'vim'
" snippets for making snippets :)
exe 'Snipp snip exe "Snipp ${1:trigger}"${2}'
@@ -14,3 +16,5 @@ exe "Snipp for for ${1:needle} in ${2:haystack}\n\t${3:\" code}\nendfor"
exe "Snipp wh wh ${1:condition}\n\t${2:\" code}\nendw"
exe "Snipp if if ${1:condition}\n\t${2:\" code}\nendif"
exe "Snipp ife if ${1:condition}\n\t${2}\nelse\n\t${3}\nendif"
+
+let &ft = ft
diff --git a/after/plugin/snipMate.vim b/after/plugin/snipMate.vim
index edebad2..f1c6602 100644
--- a/after/plugin/snipMate.vim
+++ b/after/plugin/snipMate.vim
@@ -12,6 +12,8 @@ snor ' b'
snor a
snor bi
+au FileType objc,cpp,cs let &ft .= '.c'
+
" By default load snippets in ~/.vim/snippets/
if !exists('snippets_dir')
let snippets_dir = $HOME.(has('win16') || has('win32') || has('win64') ?
diff --git a/plugin/snipMate.vim b/plugin/snipMate.vim
index e9f1978..5eba897 100644
--- a/plugin/snipMate.vim
+++ b/plugin/snipMate.vim
@@ -8,6 +8,7 @@
" For more help see snipMate.txt; you can do this by using:
" :helptags ~/.vim/doc
" :h snipMate.txt
+" Last Modified: February 28, 2009.
if exists('loaded_snips') || &cp || version < 700
finish
@@ -119,7 +120,11 @@ fun! TriggerSnippet()
call s:GetSuperTabSID()
endif
- let word = s:GetSnippet()
+ for filetype in split(&ft, '\.') " deal with dotted file-types
+ let word = s:GetSnippet(filetype)
+ if exists('s:snippet') | break | endif
+ endfor
+
" if word is a trigger for a snippet, delete the trigger & expand the snippet
if exists('s:snippet')
if s:snippet == '' " if user cancelled a multi snippet, quit
@@ -136,16 +141,16 @@ endf
" Check if word under cursor is snippet trigger; if it isn't, try checking if
" the text after non-word characters is (e.g. check for "foo" in "bar.foo")
-fun s:GetSnippet()
+fun s:GetSnippet(ft)
let origWord = matchstr(getline('.'), '\S\+\%'.col('.').'c')
wh !exists('s:snippet')
let word = s:Hash(origWord)
- if exists('s:snippets["'.&ft.'"]["'.word.'"]')
- let s:snippet = s:snippets[&ft][word]
+ if exists('s:snippets["'.a:ft.'"]["'.word.'"]')
+ let s:snippet = s:snippets[a:ft][word]
elseif exists('s:snippets["_"]["'.word.'"]')
let s:snippet = s:snippets['_'][word]
- elseif exists('s:multi_snips["'.&ft.'"]["'.word.'"]')
- let s:snippet = s:ChooseSnippet(&ft, word)
+ elseif exists('s:multi_snips["'.a:ft.'"]["'.word.'"]')
+ let s:snippet = s:ChooseSnippet(a:ft, word)
elseif exists('s:multi_snips["_"]["'.word.'"]')
let s:snippet = s:ChooseSnippet('_', word)
else