Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
List occurrences in the current buffer in the quickfix window.
VimL
Tag: 1.10

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
autoload
doc
plugin
README

README

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

DESCRIPTION
This plugin defines a command and mappings to quickly list all occurrences of
the current search pattern, passed pattern, current word or selection in the
quickfix list. This is useful to get a somewhat persistent list of matches
that act like bookmarks, so you can recall them later (when your search
pattern has changed).

HOW IT WORKS
The plugin uses :vimgrep over the current buffer.

SOURCE
Inspired by vimtip #483: Using GREP for a "list occurrences" and quickfix help
command.
    http://vim.wikia.com/wiki/Search_using_quickfix_to_list_occurrences
    command GREP :execute 'grep '.expand('<cword>') expand('%') | :copen | cc

SEE ALSO
- The GrepCommands plugin (vimscript #4173) provides additional grep commands
  covering arguments, buffers, windows and tab pages.
- The FindOccurrence plugin (vimscript #0000) can also show all occurrences of
  the <cword>, current search results, etc., but instead of the quickfix list,
  the result is either jumped to or listed.
- The SearchPosition plugin (vimscript #2634) shows the relation of the cursor
  position to the other matches of the search pattern, and provides similar
  mappings. Like the quickfix list, it can provide an orientation of where and
  how many matches there are.

RELATED WORKS
- outline (vimscript #1947) creates a custom view of the file based on regex,
  in a scratch buffer
- ttoc (vimscript #2014) is based on outline and creates a regexp-based table
  of contents of the current buffer

USAGE
:GrepHere [{pattern}]
:GrepHere /{pattern}/[g][j]
:GrepHereAdd [{pattern}]
:GrepHereAdd /{pattern}/[g][j]
                        Grep the passed pattern (or current search pattern if
                        omitted) in the current file (or the current entry of
                        the quickfix list).

<A-N>                   Grep the current search pattern in the current file
                        and show matching lines in the quickfix window (but
                        don't go there).
                        This is similar to [N defined by
                        FindOccurrence.vim, but uses the quickfix list
                        instead of just printing all matching lines.

<A-M>                   Grep the current whole word under the cursor in the
                        current file and show matching lines in the quickfix
                        window (but don't go there).
                        This is similar to [I defined by
                        FindOccurrence.vim, but uses the quickfix list
                        instead of just printing all matching lines.
g<A-M>                  Grep the current word under the cursor in the current
                        file and show matching lines in the quickfix window
                        (but don't go there).
                        Only whole keywords are searched for, like with the
                        star command.
{Visual}<A-M>           Grep the selected text in the current file and show
                        matching lines in the quickfix window (but don't go
                        there).

                        Imagine 'M' stood for "more occurrences".
                        These mappings reuse the last used <cword> when issued
                        on a blank line.
Something went wrong with that request. Please try again.