Friday, July 16, 2010

Re: Cursor position insert mode

Am 16.07.2010 11:03, schrieb d4567:
> Hello,
>
> in my script which is called while the user is in insert mode, I'd like
> to detect if the cursor is after the last character on the current line.
>
> I tried col(".") but it returns the same number regardless of whether
> the insert-mode-cursor is before or after the last character on the line.
>
> If cursor on the first column => col(".") == 1
>
> Then, when moving right, it increases of course with each step.
>
> But the step from right before the last character until behind the last
> character does *not* increase col(".") anymore.
> Is this a bug or a feature?
>
> Any ideas?

col(".") works ok, but you must stay in Insert mode when checking it.
For example, type the following starting from Normal mode:

A<C-R>=col(".")<CR><Esc>

You can replace col(".") with a function call that checks col(".") and
it will still work.

--
Andy

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

No comments: