Thursday, September 17, 2015

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

On Thu, Sep 17, 2015 at 4:42 PM, Ben Fritz <fritzophrenic@gmail.com> wrote:
> 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?
>
Maybe because in Insert mode at the end of the line, the cursor is one
past the last character on the line?

How exactly do you call synID()? In a script or at i_CTRL-O on the
command line? Or in a mapping?
Tests I did here were inconclusive.


Best regards,
Tony.

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