Friday, December 5, 2014

How to highlight keyword in comments?

My objective: to highlight all my custom keywords within comments regardless of the filetype.

Sympton: everything works fine (in Python, Cpp, etc). But in .tex file, the highlight won't work.

My code:
augroup colors_settings
autocmd!
autocmd Syntax * syn keyword globalTodo contained XXX TODO NB FIXME WARN
\ | exe "syn match globalComment +" . substitute(escape(&cms, ' ."*+'), '\s*%s', '.*', ""). "+ contains=globalTodo"
\ | hi link globalTodo Todo
\ | hi link globalComment Comment
augroup END


Example tex file:

% NB here it will be highlighed.
\documentclass[conference]{IEEEtran}

\begin{document}
\title{Network Security Through Penetration}
\maketitle

% NB here won't be higlighed.
\begin{abstract}\boldmath
\end{abstract}

\section{Conclusion}

\end{document}


The code is self contained, so it's easy to try out locally. The first NB is higlighted while the second is not.

How to highlight the second?

In case of gmail 72tw limit, a bpaste version: https://bpaste.net/show/5a1f372a98d8

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment