Skip to content

Instantly share code, notes, and snippets.

@lcw
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcw/0e51e72072d6741287ef to your computer and use it in GitHub Desktop.
Save lcw/0e51e72072d6741287ef to your computer and use it in GitHub Desktop.
" ******** Syntax highlighting
if has("syntax")
syntax clear
source $VIMRUNTIME/syntax/fortran.vim
function! TextEnableCodeSnip(filetype,start,end,textSnipHl) abort
let ft=toupper(a:filetype)
let group='textGroup'.ft
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
" Remove current syntax definition, as some syntax files (e.g. cpp.vim)
" do nothing if b:current_syntax is defined.
unlet b:current_syntax
endif
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
try
execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
catch
endtry
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
else
unlet b:current_syntax
endif
execute 'syntax region textSnip'.ft.'
\ matchgroup='.a:textSnipHl.'
\ start="'.a:start.'" end="'.a:end.'"
\ containedin=ALL
\ contains=@'.group.''
endfunction
call TextEnableCodeSnip('python','$loopy begin transform','loopy end transform', 'Comment')
endif
@lcw
Copy link
Author

lcw commented Jan 27, 2015

Put this file in ~/.vim/after/syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment