Vim regex to substitute/escape pipe characters

前端 未结 3 1338
栀梦
栀梦 2021-02-19 03:48

Let\'s suppose I have a line:

a|b|c

I\'d like to run a regex to convert it to:

a\\|b\\|c

In most regex engine

3条回答
  •  梦毁少年i
    2021-02-19 03:59

    If you use very-magic (use \v) you'll have the Perl/pcre behaviour on most special characters (excl. the vim specifics):

    :s#\v\|#\\|#g
    

提交回复
热议问题