On 26/08/11 19:24, Gerardo Marset wrote:
I'm looking for a way of knowing wether or not all the characters up to
the cursor position in the current line are spaces.
How would I do that?

Thanks!


Spaces only, or spaces and tabs, or any whitespace including (or not) no-break spaces and including (or not) CJK wide spaces (U+3000 IIRC)?

Including or excluding the cursor position?

For "true" spaces only, and not including the cursor position, what about (untested)

        if getline('.') =~ '^ \{' . col('.') - 1 . '}'
                " we are on the first nonspace, or before it
        else
                " we aren't
        endif

(it is important to use single quotes in the test-expression).

The other cases are left as an exercise to the reader, but beware of the difference between col() and virtcol()

Also, the example above should intentionally follow the "true" path whenever we are in column 1, since in that case the zero characters before the cursor contain nothing that isn't a space.


Best regards,
Tony.
--
John Birch Society -- that pathetic manifestation of organized
apoplexy.
                -- Edward P. Morgan

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

Reply via email to