Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 1. Searching for literal text. Is there a way to avoid having to manually escape special characters?

Put "set nomagic" in your .vimrc. This makes e.g. "." match a literal period/full-stop rather than any character. To get the special behaviour, escape the character: e.g., in nomagic mode, "\." matches any single character.

If you only want this behaviour occasionally, putting "\M" at the start of your search will invoke it for that search only: e.g. "/\Mfull.stops.only" will match "full.stops.only" but not "full-stops:only".

Even in nomagic mode, a few characters are treated specially, e.g. "$" for end of line. To suppress even these, start your search "\V": e.g., "/\V$1000". N.B., you can't make this behaviour permanent in your .vimrc: you can only invoke it search by search.

If you want the full gory details for all of the above, try ":help pattern" in Vim.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: