Vim regex not need \ to escape

regular expressionvim

In Vim is there an option to write regexs in the same style as Awk for example

/sp\{0,\}/
Would be

/sp{0,}/

Best Answer

Preceding your pattern with \v will make the pattern “magic”, and symbols like { and [ have an interpreted meaning (and literals need to be escaped).

So /\vsp{1,} would find what you wanted (I just tested it).

You can make this a sort of default by remapping / to /\v with the following lines in your vimrc:

nnoremap / /\v
vnoremap / /\v

See :help pattern for more.

Related Question