Thursday, September 17, 2015

Why does synID() always return zero when inserting at the end of a line?

I ran into difficulty trying to automatically format C-style comments without a middle part. I was trying to set formatoptions automatically depending on whether the cursor was inside a comment or not.

My problem was that when in insert mode at the end of a line (e.g. after using 'A'), synID() always returns zero, even if the comment region extends onto the next line.

I worked around the issue by using col('.')-1 instead of just col('.') if I'm in insert mode...but why do I need to do that?

--
--
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: