Vim:Regex
Magic mode
- magic
-
.,$,*등 몇 개의 심벌에 대해서만 특별한 의미를 유지한다. (기본)
- nomagic
-
$를 제외한 모든 심벌은 문자 그대로로 해석된다.
- very magic
- 거의 대부분의 심벌이 특수 의미를 가지며, 글자 그대로 해석하기 위해서는 이스케이프해야 한다.
- vary no magic
- 모든 심벌은 글자 그대로로 해석되며, 특수한 의미를 가지기 위해서는 이스케이프해야 한다.
Substitute Command
For each line in the range replace a match of the pattern with the string where:
-
c- Confirm each substitution -
g- Replace all occurrences in the line (withoutg- only first). -
i- Ignore case for the pattern. -
I- Don't ignore case for the pattern.
대소문자 변환 관련
-
&- 패턴에 매칭된 전체 문자. -
\U- 이후 모든 문자를 대문자로 변환 -
\u- 다음 1글자만 대문자로 변환 -
\E- 변환 끝냄
Examples
-
:%s/pattern/\U&/g - 매칭된 전체 문자 대문자화
-
:%s/\(pattern\)/\U\1/g - 매칭된 특정 그룹만 대문자로 변환
Global Command
Execute the Ex command cmd (default ":p") on the lines within [range] where pattern matches. If pattern is preceded with a ! - only where match does not occur.
Escaped characters or metacharacters
-
.- any character except new line -
\s- whitespace character -
\S- non-whitespace character -
\d- digit -
\D- non-digit -
\x- hex digit -
\X- non-hex digit -
\o- octal digit -
\O- non-octal digit -
\h- head of word character (a,b,c...z,A,B,C...Z and _) -
\H- non-head of word character -
\p- printable character -
\P- like\p, but excluding digits -
\w- word character -
\W- non-word character -
\a- alphabetic character -
\A- non-alphabetic character -
\l- lowercase character -
\L- non-lowercase character -
\u- uppercase character -
\U- non-uppercase character
yank 한 내용을 붙여넣기 하고싶다면
Ctrl + r -> "
See also
Favorite site
References
-
Vim_Regular_Expressions_101.pdf ↩