Getting the current character position of the cursor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting the current character position of the cursor

Yegappan Lakshmanan
Hi,

The getcurpos() and col() functions return the byte position of the cursor.
Is there a function that returns the character position of the cursor in
the current line?

The byteidx() function returns the byte index given the character index
in a string. I am looking for the opposite.

Thanks,
Yegappan

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7nER5%2BrkybiqZ%3Dq4EwaamaAcv59g%2BUfnYx0V%3Dh%3D_ih2jQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Getting the current character position of the cursor

Yegappan Lakshmanan

On Sat, Dec 26, 2020 at 8:58 AM Yegappan Lakshmanan <[hidden email]> wrote:
Hi,

The getcurpos() and col() functions return the byte position of the cursor.
Is there a function that returns the character position of the cursor in
the current line?

The byteidx() function returns the byte index given the character index
in a string. I am looking for the opposite.


Neovim has the vim.str_utfindex() function that returns the character
index of a given byte index in a string:


I am looking for a similar function to use in Vim.

- Yegappan
 

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7knwTHiTa-8%2BcCnMceQDPgx6pXxU_kDzvN1TbAuGCsg9w%40mail.gmail.com.