Skip to content

Instantly share code, notes, and snippets.

@igemnace
Created October 24, 2017 02:11
Show Gist options
  • Save igemnace/6b0fa07ca4f649a10f1ec555f37cf7ec to your computer and use it in GitHub Desktop.
Save igemnace/6b0fa07ca4f649a10f1ec555f37cf7ec to your computer and use it in GitHub Desktop.
Example for filetype-specific template replacement. Nice to go in your vimrc, or in $VIM/after/plugin/template-lite.vim.
function! TemplateReplace() abort
if expand('%') =~ glob2regpat('*.js')
" do JS-specific replacement
elseif expand('%') =~ glob2regpat('*.sh')
" do sh-specific replacement
endif
endfunction
augroup TemplateLite
autocmd!
autocmd User TemplateLoad call TemplateReplace()
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment