5 ms·
Vim Magic Option
- grogers 17y agoBut is there any way to set the "very magic" option in your .vimrc so you don't have to type \v every time you want to avoid a barrage of backslashes?
- mcantor 17y agoI believe there is no "very magic" nor "very nomagic" option, because the "magic" option itself is assumed to be binary by legacy vi scripts, which Mr. Moolenaar does not want to break. Also, either of those would wreck functionality on a lot of existing scripts, which make assumptions about the environment's level of magic. I had a period of time where I reflexively typed \V or \v before everything, but really, I think it's worth it to just get used to remembering which characters need to be escaped in magic mode.
- graywh 17y agoI second leaving 'magic' at its default.
- mcantor 17y agoIn addition to useful special characters in search pattern matching, vim can also do some excellent stuff in the second phrase of its substitution statements, as documented in sub-replace-special: http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-special http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replac... I find \U, \L and \E to be most useful, for example: :%s/ALL_CAPS_\(.*\)_HUZZAH/SOME_LOWERCASE_\L\1\E_HUZZAH/g Will translate "ALL_CAPS_IS_GREAT_HUZZAH" to "SOME_LOWERCASE_is_great_HUZZAH". Super handy in certain situations. It's also worth noting that these "magic" settings affect :s, :g, / and ?.