Reader small image

You're reading from  Mastering Vim

Product typeBook
Published inNov 2018
PublisherPackt
ISBN-139781789341096
Edition1st Edition
Tools
Right arrow
Author (1)
Ruslan Osipov
Ruslan Osipov
author image
Ruslan Osipov

Ruslan Osipov is a software engineer at Google, an avid traveler, and a part-time blogger. He is a self-taught engineer. He started publishing personal Vim notes in 2012, and became increasingly interested in the intricacies of the editor and its applications in optimizing development workflows.
Read more about Ruslan Osipov

Right arrow

Search or replace with regular expressions

Regular expressions (or regexes) are wonderful, and you should know how to use them. Vim, as is custom among regex implementations, has its own flavor of regex. However, once you learn one, you're comfortable with all of them.

First, let's talk about the regular (that is, the normal) search and replace command.

Search and replace

Vim supports search and replace through the :substitute command, most often abbreviated to :s. By default, :s will replace one substring with another in a current line. It has the following format:

:s/<find-this>/<replace-with-this>/<flags>

The flags are optional, and you shouldn't worry about them for now. To try it, open...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering Vim
Published in: Nov 2018Publisher: PacktISBN-13: 9781789341096

Author (1)

author image
Ruslan Osipov

Ruslan Osipov is a software engineer at Google, an avid traveler, and a part-time blogger. He is a self-taught engineer. He started publishing personal Vim notes in 2012, and became increasingly interested in the intricacies of the editor and its applications in optimizing development workflows.
Read more about Ruslan Osipov