Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emanon001/1668225 to your computer and use it in GitHub Desktop.
Save emanon001/1668225 to your computer and use it in GitHub Desktop.
Vim script: Syntax highlight of user-defined commands.
augroup syntax-highlight-extension
autocmd!
autocmd Syntax vim call s:set_syntax_of_user_defined_commands()
augroup END
function! s:set_syntax_of_user_defined_commands()
redir => _
silent! command
redir END
let command_names = map(split(_, '\n')[1:],
\ 'matchstr(v:val, ''^[!"b]*\s\+\zs\u\w*\ze'')')
if empty(command_names) | return | endif
execute 'syntax keyword vimCommand contained' join(command_names)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment