2011-11-01 6 views
7

일부 문자를 그룹화 할 빔 내에 \ (\)의 시퀀스 사용이 필요합니다. 다른 특기의 경우도 마찬가지입니다 : \ {\}.vim regexp 방언을 바꿀 수 있습니까?

regex 스타일을 perl과 비슷하게 변경할 수 있습니까? 그것을 전환하는 방법?

대신

\\(

나는 것

(

??? 당신은 기본값을 변경할 수 있습니다

답변

11

:se nomagic 
:se magic 

내가 다른 매핑을 깨는 피하기 위해 대신 해당 이스케이프를 사용하는 것이 좋습니다 것 :he magic

를 참조하십시오 '마법 레벨'이 필요합니다. 당신이 pattern.txt 도움에서 펄 정규식

과 기대처럼

/\v(\d+) 

연속 숫자와 일치합니다 :

Examples: 
after: \v  \m  \M  \V   matches ~ 
       'magic' 'nomagic' 
      $  $  $  \$   matches end-of-line 
      .  .  \.  \.   matches any character 
      *  *  \*  \*   any number of the previous atom 
     ()  \(\)  \(\)  \(\)  grouping into an atom 
      |  \|  \|  \|   separating alternatives 
      \a  \a  \a  \a   alphabetic character 
      \\  \\  \\  \\   literal backslash 
      \.  \.  .  .   literal dot 
      \{  {  {  {   literal '{' 
      a  a  a  a   literal 'a' 

{only Vim supports \m, \M, \v and \V} 

It is recommended to always keep the 'magic' option at the default setting, 
which is 'magic'. This avoids portability problems. To make a pattern immune 
to the 'magic' option being set or not, put "\m" or "\M" at the start of the 
pattern. 
+0

죄송 @Johnsyweb을 동시에 편집 : 도움을 주셔서 감사합니다! – sehe

관련 문제