MG.
MG.

Reputation: 449

Vim match space but do not match tab

Have text like the following:

size    O
5   O
length  O
812 O
lb  O
line    O
rate    O

most of the delimiters in the text are <TAB> while some of the outliers are 4 <SPACE>. trying to only find the SPACE but not TAB

Using :/\s\+ matches both <TAB> AND <SPACE> for some reason. wondering how to exclude <TAB> matches

Upvotes: 0

Views: 227

Answers (1)

romainl
romainl

Reputation: 196886

Using :/\s\+ matches both <TAB> AND <SPACE> for some reason.

Well, :help \s says:

\s  whitespace character: <Space> and <Tab>     */\s*

which is more or less consistant with basically every current regular expression dialect so I'm not sure what is surprising about this.

"More or less" because those dialects generally match other characters as well, like \r, while Vim's \s only matches spaces and tabs.

If you want to match a space, just use a literal space:

/ \+

Upvotes: 1

Related Questions