문제

I intend to fold all the lines ending in { but not classes. So far I have came up with this command :

:%g/.\{-}\(class\)\@!.*{$/normal! zf%

But this would match also the lines containing class.

도움이 되었습니까?

해결책

There are several problems:

  1. From :help /\@!: "You can't use "\@!" to look for a non-match before the matching position". Use \@<!, include the possible characters in between in there, and drop the useless (because it's not anchored) non-greedy first match.
  2. The :global command places the cursor on the first column of matching lines, so add a $ to make the % work all the time.
  3. Subsequent inner folds must be defined with the outer fold open: zv.

Ergo:

:%g/\%(class.*\)\@<!{$/normal! $zvzf%
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top