2011-11-01 7 views
7

いくつかの文字をグループ化するためにVim内で\(\)のシーケンス使用が必要です。他のスペシャルと同じ動作があります:\ {\}。vim regexp方言を変更することはできますか?

regexスタイルをperlのように変更することはできますか?それを切り替えるには?

代わり

\\(

私は

(

でしょう?

答えて

11

あなたはデフォルトを変更することができますが、「魔法レベル」

:se nomagic 
:se magic 

:he magic

を参照してください必要私はあなたの他のマッピングを壊す避けるために、代わりに、対応するエスケープを使用してお勧めします。あなたはpattern.txtヘルプからPerlの正規表現

と期待するように

/\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

関連する問題