Say the line is:
^<space1><space2><tab1><tab2><space3><space4><tab3><tab4><space5><space6><tab5><tab6><space7><space8>blablabla
So how to match all these <space>
?
(FYI, I use call matchadd("yqi_faulty_indent", '<THE_REGEX>')
to highlight it)
- With
^\t*\zs\ \+
, it matches only<space1><space2>
- With
^\s*\zs\ \+
, it matches only<space7><space8>
due to the greedy mode I think - With
^\s\{-}\zs\ \+
, it matches only<space1><space2>
due to the non-greedy mode I think - With
\v((^\s*)@<= +)
, it matches what I want, BUT, with lookaround regex, there's unacceptable high CPU when there are long lines likeseq 1 30000 | tr '\n' ' ' | fold -w 3000 | vim -
UPDATE
According to the important hint from Vivian's answer, below is my latest solution:
call matchadd("yqi_faulty_indent", '\v((^\s*)@80<= +)')
highlights blankspaces in TAB indentcall matchadd("yqi_faulty_indent", '\v((^\s*)@80<=\t+)')
highlights TABs in blankspace indent
While as mentioned in comment, there's size limitation, looking forwards furthur better solution...