Skip to Content
Practical Vim, 2nd Edition
book

Practical Vim, 2nd Edition

by Drew Neil
October 2015
Intermediate to advanced
356 pages
7h 54m
English
Pragmatic Bookshelf
Content preview from Practical Vim, 2nd Edition
Tip 78Stake the Boundaries of a Match

Sometimes we might want to specify a broad pattern and then focus on a subset of the match. Vim’s \zs and \ze items allow us to do just that.

Up until now, we’ve assumed a complete overlap between search patterns and the matches they generate. It’s time to pry these apart into two separate concepts. Let’s start by defining them. When we talk of a pattern, we refer to the regular expression (or literal text) that we type into the search field. When we talk of a match, we refer to any text in the document that appears highlighted (assuming the ‘hlsearch’ option is enabled).

The boundaries of a match normally correspond to the start and end of a pattern. But we can use the \zs and \ze items to crop the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Modern Vim

Modern Vim

Drew Neil
Learning the vi and Vim Editors, 7th Edition

Learning the vi and Vim Editors, 7th Edition

Arnold Robbins, Elbert Hannah, Linda Lamb

Publisher Resources

ISBN: 9781680501629Errata Page