Search and search-and-replace in Vim

The Basics and Beyond

Article from Issue 147/2013
Author(s):

We show you how to build on the basic functionality of Vim by introducing some useful search commands.

As a descendant of vi, a text editor written in 1976, Vim could be the oldest application on any Linux system. Most distributions include it by default, and few users have never been exposed to it. However, very few learn more than the basics of functioning within Vim. To most, intricacies like the different ways to search remain forever mysteries.

Staying at this level of knowledge is in some ways understandable. With its dozens of commands and plugins, Vim can feel less like a text editor than a choice of lifestyle (even if you don’t get involved in the traditional rivalry with Emacs). However, confining yourself to searching by eye and arrow keys is need-lessly limited. You can easily choose your level of knowledge by learning a handful of additional search commands, by using Vim’s internal version of grep, or even by adding a few plugins to enhance the control you have. Many of the commands are organized so that you can remember their variations easily.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line – vim-abolish

    Whether you are writing code or text, vim-abolish can help you customize search and replace functions in Vim.

  • AltSearch

    AltSearch offers extended functionality to LibreOffice Write's default find and replace tools, making it ideal for editing and formatting longer documents.

  • rename

    The rename command is a powerful means to simultaneously rename or even move multiple files following a given pattern.

  • Command Line: Grep

    Once you understand the intricacies of grep, you can find just about anything.

  • Workspace: OpenOffice.org Macros

    Dmitri shows you how to compose and publish your blog from OpenOffice.org.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News