- Mastering Vim
- Ruslan Osipov
- 233字
- 2021-06-10 18:51:31
Searching across files
Vim has two commands to help you search across files, :grep and :vimgrep:
- :grep uses system grep, and is a great tool if you're already familiar with how grep works
- :vimgrep is a part of Vim, and might be easier to use if you are not already familiar with grep
We'll focus on :vimgrep, since the grep tool is outside the scope of this book.
The syntax is as follows: :vimgrep <pattern> <path>. pattern could either be a string or a Vim-flavored regular expression. path will often be a wildcard; use ** as a path to search recursively (or **/*.py to restrict by filetype).
Let's try searching for a calc substring in our code base:
:vimgrep animal **/* .py
This will take us to the first match, displaying the number of matches at the bottom of the screen:
To navigate through the matches, use :cn or :cp. However, you might want to open a visual quickfix window by using :copen, as follows:
You can navigate the quickfix list with the j and k keys and jump to a match by pressing Enter. The quickfix window can be closed like any other window by typing :q or running Ctrl + w, q. You can read more about it in the Quickfix List section in Chapter 5, Build, Test, and Execute.
- WildFly:New Features
- Visual C++程序設(shè)計(jì)教程
- LaTeX Cookbook
- Kali Linux Web Penetration Testing Cookbook
- Computer Vision for the Web
- Mastering Adobe Captivate 2017(Fourth Edition)
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- 深入淺出Prometheus:原理、應(yīng)用、源碼與拓展詳解
- 跟老齊學(xué)Python:輕松入門(mén)
- MATLAB定量決策五大類(lèi)問(wèn)題
- Mastering KnockoutJS
- Julia高性能科學(xué)計(jì)算(第2版)
- Microsoft Dynamics AX 2012 R3 Financial Management
- C語(yǔ)言程序設(shè)計(jì)
- Three.js權(quán)威指南:在網(wǎng)頁(yè)上創(chuàng)建3D圖形和動(dòng)畫(huà)的方法與實(shí)踐(原書(shū)第4版)