On Fri, 23 Jun 2006, Peter Slizik wrote:


Hello Vimmers,

I'd like to write a mapping that would expand to a function call. I want this
function to return a meaningful text in a normal context, but nothing at all,
if it's called from a comment or string context. I know this has been done
many times before, I need only a hint to know where to start.

To check if the cursor is within a comment or string context:

  synIDattr(synID(line("."), col("."), 1), "name") =~? 'comment\|string'

Syntax has to be enabled.

See

  :help synID()
  "expression register
  :help i_ctrl-r

HTH.
--
Gerald

Reply via email to