Thursday, September 1, 2011

Re: Check for spaces at the start of the current line

El 01/09/11 14:47, Andy Wokula escribió:
> Am 26.08.2011 19:24, schrieb Gerardo Marset:
>> 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!
>
> I'd use the following test (echos 1 (= true) if cursor is on initial
> white-space):
>
> :echo virtcol(".")-1 < indent(".")
>
>
> Example: a mapping for the <Home> key
>
> :noremap <expr> <Home> virtcol(".")-1==indent(".")?"<Bar>":"^"
>
Nice!
However that code takes tabs into account too, as well as, maybe, other
whitespace characters I didn't try.

Thanks anyway, i'll definitely save it, it migth come in handy later :).

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