In vim, is there a way to set “very magic” permanently and globally?

前端 未结 3 1602
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 01:41

I use \"very magic\" for regexp searches (i.e. /\\v or %s/\\v) but I wish I could set some option so I don\'t have to include \\v anymore, anywhere. Is there a way to do thi

3条回答
  •  佛祖请我去吃肉
    2020-12-24 02:15

    To reply to the answer above as I can't comment yet, from How to make substitute() use another magic mode?, the vim docs and my own testing, smagic (and sm) only enters magic mode and not very magic mode.

                            *:snomagic* *:sno*
    :[range]sno[magic] ...  Same as `:substitute`, but always use 'nomagic'.
                {not in Vi} 
    
                            *:smagic* *:sm*
    :[range]sm[agic] ...    Same as `:substitute`, but always use 'magic'.
                {not in Vi}
    

    For example, one should ('s turn into )'s in a file with :%sm/(/)/g and not :%sm/\(/\)/g, which shows the following for me

    E54: Unmatched \(
    E54: Unmatched \(
    E476: Invalid command
    

    Instead, to enter very magic mode, one should use \v in the search expression of substitute (i.e. :%s/\v\(/\)/g) (Please correct me if I've messed up, I am quite new to Vim)

提交回复
热议问题