Monday, August 12, 2013

Re: why does /\[^\s] not find the character 's'?

On 12/08/13 06:28, Ben Fritz wrote:
> On Sunday, August 11, 2013 8:38:56 PM UTC-5, tom arnall wrote:
>> greetings!
>>
>>
>>
>> when i do a search using:
>>
>>
>>
>> /\[^\s]
>>
>>
>> it behaves as it shd, i.e., it finds anything that's not a whitespace,
>
> No, it doesn't. I assume you're using "nomagic" so that \[...] is a collection, not a literal '[' character and some other stuff.
>
> Inside a collection, \s does NOT mean whitespace. It means a '\' character or an 's' character. So you're actually matching "anything not a backslash and not the letter 's'" which WILL match whitespace. See just below :help /\] for a list of the ONLY backslash codes recognized inside [...].
>
> I think you want \S (by itself, not within [^...].
>

Tom: /\S is indeed the fastest way to search for the next nonblank. But
if you're dead set on using a collection (or if you want to match
something that's neither whitespace nor {something}) you can use

/[^[:blank:]]

with 'magic', or

/\[^[:blank:]]

with 'nomagic'. ('magic' on is the default, even in 'compatible' mode,
and is the recommended setting, see :help 'magic'.)


Best regards,
Tony.
--
"The fact that there is a general belief in
a future life is no evidence of its truth."
[Clarence Darrow]

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: