2−2.の場合 let s:colors={} function! SetColor() let line = getline(".") let rh = {} let pattern = '#[0-9a-fA-F]\{6}\>' call substitute(line,pattern,'\=empty(extend(rh,{submatch(0):1}))','g') let rs = keys(rh) for c in rs if !has_key(s:colors,c) let hlname = c[1:] exec printf('syntax match HL_%s /%s\>/ containedin=ALL',hlname,c) exec printf('highlight HL_%s guibg=%s',hlname,c) endif endfor return '' endfunction