On 15-Mar-2010 11:21, Gregor Uhlenheuer wrote:
Since you nearly guessed my use of col() - I want to get the length of
the current line - thank you for the tip with the substitution. I
figured that using virtcol() is probably more appropriate for that
purpose.

Well, call it psychic debugging power ;-)

To prevent anyone reading this from falling into another trap, I'd like to stress that virtcol() and the substitution I suggested are *not equivalent*!

The substitution counts the number of characters (as in "ABC" = 3), whereas virtcol() is concerned with the screen width that characters occupy (as in "A" = one column, "<Tab>" = 1..8 columns, "^V" (or other unprintable chars or the whole range of double-width Asian Kanji characters = 2).

In short, if you're concerned with indenting or fitting text into a given width, use virtcol(), if you're interested in the number of chars, use the substitution count, and use col() for the physical number of bytes used to represent the string.

-- regards, ingo

--
You received this message from the "vim_dev" 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

Reply via email to