Contents
Can you use magic and regular expressions in Vim?
Vim’s default ‘magic’ setting makes characters have the same meaning as in grep, and \\v (very magic) makes them the same as the extended regular expressions used by egrep. Regular expressions in scripts should always specify one of \\v , \\m , \\M , or \\V , to make them immune to the user’s ‘magic’ setting.
Can you use a literal string in Vim?
As we mentioned in the chapter on Strings, Vim allows you to use single quotes to define a “literal string” that passes through characters directly. For example, the string ‘a b’is four characters long. Can we use literal strings to avoid having to type those double backslashes?
How are metacharacters used in regexps in Vim?
The power of regexps is in the use of metacharacters. These are types of characters which have special meaning inside the search pattern. With a few exceptions these metacharacters are distinguished by a “magic” backslash in front of them. The table below lists some common VIM metacharacters.
How to make all VIM characters have special meaning?
Thankfully, any Vim search pattern can include the special sequence \\v (very magic), and this will make every following character except a-zA-Z0-9 and ‘_’ have special meaning. Using \\V has the opposite effect: all characters have their literal meaning and must be preceded by \\ to activate their special meaning.
Is the Vim regexp syntax compatible with Perl?
Today, the so called “Perl compatible” regular expressions are the de-facto default in most languages, but Vim regular expressions are not compatible with Perl-compatible expressions! Vim regexp syntax goes back to at least the ’70’s, when Perl wasn’t even around.
What makes Vim such a good programming language?
VIM has all features of a modern programmer’s editor – macro language, syntax highlighting, customizable user interface, easy integration with various IDEs plus a set of features which makes VIM so attractive to its users: crash recovery, automatic commands, session management. VIM has a very broad and loyal user base.