Skip to content

Vim:Regex

Magic mode

magic
., $, * 등 몇 개의 심벌에 대해서만 특별한 의미를 유지한다. (기본)
nomagic
$ 를 제외한 모든 심벌은 문자 그대로로 해석된다.
very magic
거의 대부분의 심벌이 특수 의미를 가지며, 글자 그대로 해석하기 위해서는 이스케이프해야 한다.
vary no magic
모든 심벌은 글자 그대로로 해석되며, 특수한 의미를 가지기 위해서는 이스케이프해야 한다.

Substitute Command

:range s[ubstitute]/pattern/string/cgiI

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 (without g - only first).
  • i - Ignore case for the pattern.
  • I - Don't ignore case for the pattern.

Global Command

:range g[lobal][!]/pattern/cmd

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


  1. Vim_Regular_Expressions_101.pdf