Saluton Andrey :) On Wed 20 May 2009 14:23 +0200, Andrey Zhidenkov <[email protected]> dixit: > When I've started to use a regular expressions in vim search and replace, > I've noticed > that I need to escape symbols '(', '+' and etc. > > For example, instead of executing > > %s/^\s+// > > i need to type > > %s/^\s\+// > > Can anybody explain me this feature? I know, that I can use ':' as delimiter, > but I > think Perl syntax is more sufficient for me.
Try ":help magic" (do this first...) and ":%s/^\v\s+//" afterwards. If you don't want to backslash each and every special char, use "set magic", which is "on" by default. This doesn't avoid the backslash over ALL the special chars (for example "+" has to be backslashed even if the "magic" option is on), but most of the time is enough. If you want the special chars have their "speciality" on, then use "\v" before the patter you want to match. This turns on "very magic" mode, and then most of the special chars will be special without backslashing them. On the other hand, if you have to match some of those characters literally, then you will need to backslash them. E.g. "\va+b" matches one or more "a" followed by a "b", while "\va\+b" will match "a+b". See ":help pattern-overview" for better and more detailed information. -- Raúl "DervishD" Núñez de Arenas Coronado Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen! --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
