diff --git a/after/ftplugin/c_snips.vim b/after/ftplugin/c_snips.vim index 78a3659..3061755 100644 --- a/after/ftplugin/c_snips.vim +++ b/after/ftplugin/c_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_c_snips') fini en let s:did_c_snips = 1 -let ft = &ft -let &ft ='c' +let snippet_filetype = 'c' " main() exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}" @@ -56,4 +55,3 @@ 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 0ff2449..da9ae31 100644 --- a/after/ftplugin/html_snips.vim +++ b/after/ftplugin/html_snips.vim @@ -1,13 +1,11 @@ -let filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html' -if !exists('g:loaded_snips') || exists('s:did_'.filetype.'_snips') +let snippet_filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html' +if !exists('g:loaded_snips') || exists('s:did_'.snippet_filetype.'_snips') fini en -let s:did_{filetype}_snips = 1 -let ft = &ft -let &ft = filetype +let s:did_{snippet_filetype}_snips = 1 " automatically add a closing '/' to the end of xhtml tags -let c = filetype == 'xhtml' ? ' /' : '' +let c = snippet_filetype == 'xhtml' ? ' /' : '' " Some useful Unicode entities " Non-Breaking Space @@ -95,4 +93,3 @@ exe 'Snipp optt ${2}' exe "Snipp select ${5}" exe "Snipp table \n\t\n\t\n
${2:Header}
${3:Data}
${4}" exe 'Snipp textarea ${5}' -let &ft = ft diff --git a/after/ftplugin/java_snips.vim b/after/ftplugin/java_snips.vim index 8cb6402..8e5963d 100644 --- a/after/ftplugin/java_snips.vim +++ b/after/ftplugin/java_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_java_snips') fini en let s:did_java_snips = 1 -let ft = &ft -let &ft ='java' +let snippet_filetype = 'java' exe "Snipp main public static void main (String [] args)\n{\n\t${1:/* code */}\n}" exe 'Snipp pu public' @@ -41,5 +40,3 @@ 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 d28a807..6a65be4 100644 --- a/after/ftplugin/javascript_snips.vim +++ b/after/ftplugin/javascript_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_js_snips') fini en let s:did_js_snips = 1 -let ft = &ft -let &ft ='javascript' +let snippet_filetype = 'javascript' " Prototype exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};" @@ -37,5 +36,3 @@ 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 edefa2e..da4c820 100644 --- a/after/ftplugin/objc_snips.vim +++ b/after/ftplugin/objc_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_objc_snips') fini en let s:did_objc_snips = 1 -let ft = &ft -let &ft ='objc' +let snippet_filetype = 'objc' " #import <...> exe 'Snipp imp #import <${1:Cocoa/Cocoa.h}>${2}' @@ -54,5 +53,3 @@ 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 413034a..4bf9bba 100644 --- a/after/ftplugin/perl_snips.vim +++ b/after/ftplugin/perl_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_perl_snips') fini en let s:did_perl_snips = 1 -let ft = &ft -let &ft ='perl' +let snippet_filetype = 'perl' " Hash Pointer exe 'Snipp . =>' @@ -37,5 +36,3 @@ 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 69f7ff5..3998354 100644 --- a/after/ftplugin/php_snips.vim +++ b/after/ftplugin/php_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_php_snips') fini en let s:did_php_snips = 1 -let ft = &ft -let &ft ='php' +let snippet_filetype = 'php' exe "Snipp php " exe 'Snipp ec echo "${1:string}"${2};' @@ -67,4 +66,3 @@ 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 eb4e9e0..40595e6 100644 --- a/after/ftplugin/python_snips.vim +++ b/after/ftplugin/python_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_python_snips') fini en let s:did_python_snips = 1 -let ft = &ft -let &ft ='python' +let snippet_filetype = '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}" @@ -28,5 +27,3 @@ 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 374c65b..62ce03d 100644 --- a/after/ftplugin/ruby_snips.vim +++ b/after/ftplugin/ruby_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_ruby_snips') fini en let s:did_ruby_snips = 1 -let ft = &ft -let &ft ='ruby' +let snippet_filetype = 'ruby' " New Block exe "Snipp =b =begin rdoc\n\t${1}\n=end" @@ -167,4 +166,3 @@ 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 b5f498b..822165f 100644 --- a/after/ftplugin/sh_snips.vim +++ b/after/ftplugin/sh_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_sh_snips') fini en let s:did_sh_snips = 1 -let ft = &ft -let &ft = 'sh' +let snippet_filetype = 'sh' exe "Snipp if if [[ ${1:condition} ]]; then\n\t${2:#statements}\nfi" exe "Snipp elif elif [[ ${1:condition} ]]; then\n\t${2:#statements}" @@ -11,5 +10,3 @@ 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 aa0d6c2..8d08580 100644 --- a/after/ftplugin/tex_snips.vim +++ b/after/ftplugin/tex_snips.vim @@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_tex_snips') fini en let s:did_tex_snips = 1 -let ft = &ft -let &ft = 'tex' +let snippet_filetype = 'tex' " \begin{}...\end{} exe "Snipp begin \\begin{${1:env}}\n\t${2}\n\\end{$1}" @@ -49,5 +48,3 @@ 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 459a152..6342c98 100644 --- a/after/ftplugin/vim_snips.vim +++ b/after/ftplugin/vim_snips.vim @@ -2,8 +2,7 @@ if !exists('g:loaded_snips') || exists('s:did_vim_snips') fini en let s:did_vim_snips = 1 -let ft = &ft -let &ft = 'vim' +let snippet_filetype = 'vim' " snippets for making snippets :) exe 'Snipp snip exe "Snipp ${1:trigger}"${2}' @@ -16,5 +15,3 @@ 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 3363209..cc7e36d 100644 --- a/after/plugin/snipMate.vim +++ b/after/plugin/snipMate.vim @@ -12,7 +12,7 @@ snor ' b' snor a snor bi -au FileType objc,cpp,cs let &ft .= '.c' +au FileType objc,cpp,cs let &ft = expand('').'.c' " By default load snippets in ~/.vim/snippets/ if !exists('snippets_dir') diff --git a/plugin/snipMate.vim b/plugin/snipMate.vim index 5eba897..4b8180d 100644 --- a/plugin/snipMate.vim +++ b/plugin/snipMate.vim @@ -16,7 +16,7 @@ endif let loaded_snips = 1 if !exists('snips_author') | let snips_author = 'Me' | endif -com! -nargs=+ -bang Snipp call s:MakeSnippet(, &ft, 0) +com! -nargs=+ -bang Snipp call s:MakeSnippet(, snippet_filetype, 0) com! -nargs=+ -bang GlobalSnip call s:MakeSnippet(, '_', 0) let s:snippets = {} | let s:multi_snips = {} @@ -133,9 +133,8 @@ fun! TriggerSnippet() let col = col('.')-len(word) sil exe 's/'.escape(word, '.^$/\*[]').'\%#//' return s:ExpandSnippet(col) - elseif exists('s:snipPos') - return s:JumpTabStop() endif + if exists('s:snipPos') | return s:JumpTabStop() | endif return exists('s:sid') ? {s:sid}_SuperTab('n') : "\" endf