Giter VIP home page Giter VIP logo

vimgrepbuffer's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=3233

This plugin provides easy application of the 'vimgrep' command on buffers
(as opposed to the filesystem, which is its normal mode of operation).
It provides two commands: one to search just the current buffer, and the
other to search all listed buffers.
The QuickFix buffer will be populated with the search results, if any, and
opened for viewing. The search pattern will also be assigned to the search
register, so that matches will be highlighted if 'hlsearch' is on (':set
hlsearch').

Two commands are provided, ':G' and ':GG'. The first limits the search to
the current buffer, while the second searches all listed buffers.

If you do not like the cryptic/genericness of these 'short' commands, put:

    let g:vimgrepbuffer_long_command = 1

in your "~/.vimrc", and ':VimgrepBuffer' and ':VimgrepBuffers' will be set as
the commands instead.

The pattern specification is *exactly* like that for 'vimgrep'.  This means
that if the pattern starts with a non-identifier character or contains any literal whitespace
characters, for correct behavior you will have to enclose the pattern in
delimiter characters (e.g. "/", "@", "#"):

   :G /\s*print "\d/
   :GG /\s*def\s\+\w\+(/
   :G /\(def\s\+\|class\s\+\)/
   :GG /\cisland/
   :G /the quick brown \w\+/
   :GG /except \+\w\+Error/

If your pattern starts with an identifier-character you can omit the enclosing
delimiters:

   :G def\s\+\w\+(.*\*\*kwargs)
   :GG except\s\+\w\+Error

In this latter case, the pattern will be considered to be
whitespace-delimited, and so if your pattern contains any literal whitespace
you may get incorrect results. This behavior is exactly like that of
'vimgrep'.

You might also be interested in looking at "grep.vim" (http://www.vim.org/scripts/script.php?script_id=311) as an alternative for "grep-on-buffer" operations, especially if you want to use external grep programs.
"grep.vim" provides a much broader range of functionality and commands, and is typically faster.  However, the grep dialect you will have to use is that of the external grep programs, rather than that of Vim. The main reason I wrote "VimgrepBuffer" (and why you might be interested in using it) is to be able to use Vim's grep dialect to express the search patterns. 

vimgrepbuffer's People

Contributors

jeetsukumaran avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.