I have file where I would like to indent all the lines between curly braces:
html {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
body {
line-height: 1.5;
color: black;
background: white;
}
I could do this with :g/{/ .+1,/}/-1 >
Ex
command. However, I also tried to do the same with regular expression :g/\v\{\_s?\zs\_.{-}\ze\}/ >
. This will match all the lines between curly braces and I expected >
command to indent the matched lines. Instead, it indents the html {
and body {
lines:
html {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
body {
line-height: 1.5;
color: black;
background: white;
}
What is the reason for such behavior?
:h global
:for a multi-line pattern, only the start of the match matters
; so it only considers just two lines that your matchs start. here the lines include\zs
exactly after{
's and indent them. – dNitro Aug 24 '16 at 21:57gg=G
? – romainl Aug 24 '16 at 22:17\zs
matches on the line following the '{' since\_s?
matches a newline. But:global
marks lines at the start of the entire matching process, even if\zs
matches on a subsequent line. Unless that's what you meant; I'm not sure :-) – Antony Sep 4 '16 at 20:33