원래 정규식이 한글을 지원한다면 한글의 범위는 [가-힣](또는 [\uac00-\ud7a3])으로 표현돼야 할 텐데..
VIM에서는 기본적으로 이게 안된다는 것 같다.
그래서 여길 참고해서 https://kldp.org/node/101253 어떻게든 대충 해결하긴 했다.
ASCII의 범위가 \x00 - \xff 니까, 한글은 여기에 속하지 않을 것이다.
따라서 :%s/\([^\x00-\xff]\)[ ]/\1\r/g 와 같이 사용하면 된다.
Replacement Part of :substitute
Replacement part of the S&R has its own special characters which we are going to use to fix grammar:
# | Meaning | # | Meaning |
& | the whole matched pattern | \L | the following characters are made lowercase |
\0 | the whole matched pattern | \U | the following characters are made uppercase |
\1 | the matched pattern in the first pair of \(\) | \E | end of \U and \L |
\2 | the matched pattern in the second pair of \(\) | \e | end of \U and \L |
... | ... | \r | split line in two at this point |
\9 | the matched pattern in the ninth pair of \(\) | \l | next character made lowercase |
~ | the previous substitute string | \u | next character made uppercase |
Now the full S&R to correct non-capital words at the beginning of the sentences looks like
s:\([.!?]\)\s\+\([a-z]\):\1 \u\2:g
We have corrected our grammar and as an extra job we replaced variable number of spaces between punctuation and the first letter of the next sentence with exactly two spaces.
http://vimregex.com/#backreferences