• Stars
    star
    145
  • Rank 252,660 (Top 6 %)
  • Language
    Vim Script
  • License
    BSD 2-Clause "Sim...
  • Created about 9 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔍 Enhanced in-file search for Vim

loupe

Intro

"loupe (noun)
a small magnifying glass used by jewelers and watchmakers."

loupe-features

Loupe enhances Vim's search-commands in four ways:

1. Makes the currently selected match easier to see

When searching using /, ?, star, #, n, N or similar, it can be hard to see the "current" match from among all the matches that 'hlsearch' highlights. Loupe makes the currently selected match easier to see by:

  • Applying a different :highlight group (by default, hl-IncSearch) to the match under the cursor.
  • Keeping the matching line centered within the window when jumping between matches with n and N.

2. Applies sane pattern syntax by default

Loupe makes "very magic" (/\v) syntax apply by default when searching. This is true even if you initiate a search via a novel means, such as from a visual selection or with a complicated :range prefix.

This means that you can use a pattern syntax closer to the familiar regular expression syntax from languages such as Perl, Ruby, JavaScript (indeed, most other modern languages that support regular expressions).

3. Provides a shortcut to remove search highlighting

Loupe maps <leader>n to quickly remove all 'hlsearch' highlighting (although you can provide an alternative mapping of your choosing or suppress the feature entirely).

4. Sensible defaults for search-related features

Loupe provides reasonable defaults for most search-related Vim settings to provide a good "out of the box" experience. For more details, or to see how to override Loupe's settings, see loupe-overrides.

Installation

To install Loupe, use your plug-in management system of choice.

If you don't have a "plug-in management system of choice", I recommend Pathogen (https://github.com/tpope/vim-pathogen) due to its simplicity and robustness. Assuming that you have Pathogen installed and configured, and that you want to install Loupe into ~/.vim/bundle, you can do so with:

git clone https://github.com/wincent/loupe.git ~/.vim/bundle/loupe

Alternatively, if you use a Git submodule for each Vim plug-in, you could do the following after cd-ing into the top-level of your Git superproject:

git submodule add https://github.com/wincent/loupe.git ~/vim/bundle/loupe
git submodule init

To generate help tags under Pathogen, you can do so from inside Vim with:

:call pathogen#helptags()

Mappings

<Plug>(LoupeClearHighlight)

Loupe maps <leader>n to <Plug>(LoupeClearHighlight), which clears all visible highlights (like :nohighlight does). To use an alternative mapping instead, create a different one in your .vimrc instead using :nmap:

" Instead of <leader>n, use <leader>x.
nmap <leader>x <Plug>(LoupeClearHighlight)

Note that Loupe will not try to set up its <leader>n mapping if any of the following are true:

<Plug>(LoupeOctothorpe)

Loupe maps # to <Plug>(LoupeOctothorpe) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(LoupeOctothorpe)

<Plug>(LoupeStar)

Loupe maps star to <Plug>(LoupeStar) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(LoupeStar)

<Plug>(LoupeN)

Loupe maps N to <Plug>(LoupeN) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(LoupeN)

<Plug>(LoupeGOctothorpe)

Loupe maps g# to <Plug>(LoupeGOctothorpe) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(LoupeGOctothorpe)

<Plug>(LoupeGStar)

Loupe maps gstar to <Plug>(LoupeGStar) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(LoupeGStar)

<Plug>(Loupen)

Loupe maps n to <Plug>(Loupen) in order to implement custom highlighting and line-centering for the current match.

To prevent this from happening, create an alternate mapping in your .vimrc:

nmap <Nop> <Plug>(Loupen)

Options

g:LoupeHighlightGroup

g:LoupeHighlightGroup (string, default: IncSearch)

Specifies the :highlight group used to emphasize the match currently under the cursor for the current search pattern. Defaults to "IncSearch" (ie. hl-IncSearch). For example:

let g:LoupeHighlightGroup='Error'

To prevent any special highlighting from being applied, set this option to "" (ie. the empty string).

g:LoupeLoaded

g:LoupeLoaded (any, default: none)

To prevent Loupe from being loaded, set g:LoupeLoaded to any value in your .vimrc. For example:

let g:LoupeLoaded=1

g:LoupeClearHighlightMap

g:LoupeClearHighlightMap (boolean, default: 1)

Controls whether to set up the <Plug>(LoupeClearHighlight) mapping. To prevent any mapping from being configured, set to 0:

let g:LoupeClearHighlightMap=0

g:LoupeVeryMagic

g:LoupeVeryMagic (boolean, default: 1)

Controls whether "very magic" pattern syntax (/\v) is applied by default. To disable, set to 0:

let g:LoupeVeryMagic=0

g:LoupeCenterResults

g:LoupeCenterResults (boolean, default: 1)

Controls whether the match's line is vertically centered within the window when jumping (via n, N etc). To disable, set to 0:

let g:LoupeCenterResults=0

g:LoupeCaseSettingsAlways

g:LoupeCaseSettingsAlways (boolean, default: 1)

Normally Vim will respect your 'smartcase' and 'ignorecase' settings when searching with /, or ?, but it ignores them when using star, #, gstar or g#.

This setting forces Vim to respect your 'smartcase' and 'ignorecase' settings in all cases. To disable, set to 0:

let g:LoupeCaseSettingsAlways=0

Functions

loupe#hlmatch()

loupe#hlmatch()

Apply highlighting to the current search match.

Overrides

Loupe sets a number of search-related Vim settings to reasonable defaults in order to provide a good "out of the box" experience. The following overrides will be set unless suppressed or overridden (see loupe-suppress-overrides):

loupe-history-override

'history'

Increased to 1000, to increase the number of previous searches remembered. Note that Loupe only applies this setting if the current value of 'history' is less than 1000.

loupe-hlsearch-override

'hlsearch'

Turned on (when there is a previous search pattern, highlight all its matches).

loupe-incsearch-override

'incsearch'

Turned on (while typing a search command, show where the pattern matches, as it was typed so far).

loupe-ignorecase-override

'ignorecase'

Turned on (to ignore case in search patterns).

loupe-shortmess-override

'shortmess'

Adds "s", which suppresses the display of "search hit BOTTOM, continuing at TOP" and "search hit TOP, continuing at BOTTOM" messages.

loupe-smartcase-override

'smartcase'

Turned on (overrides 'ignorecase', making the search pattern case-sensitive whenever it containers uppercase characters).

loupe-suppress-overrides

Preventing Loupe overrides from taking effect

To override any of these choices, you can place overrides in an after-directory (ie. ~/.vim/after/plugin/loupe.vim). For example:

 " Override Loupe's 'history' setting from 1000 to 10000.
 set history=10000

 " Reset Loupe's 'incsearch' back to Vim default.
 set incsearch&vim

 " Remove unwanted 's' from 'shortmess'.
 set shortmess-=s

Related

Just as Loupe aims to improve the within-file search experience, Ferret does the same for multi-file searching and replacing:

Website

The official Loupe source code repo is at:

A mirror exists at:

Official releases are listed at:

License

Copyright 2015-present Greg Hurrell. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Development

Contributing patches

Patches can be sent via mail to [email protected], or as GitHub pull requests at: https://github.com/wincent/loupe/pulls

Cutting a new release

At the moment the release process is manual:

  • Perform final sanity checks and manual testing
  • Update the loupe-history section of the documentation
  • Verify clean work tree:
git status
  • Tag the release:
git tag -s -m "$VERSION release" $VERSION
  • Publish the code:
git push origin main --follow-tags
git push github main --follow-tags
  • Produce the release archive:
git archive -o loupe-$VERSION.zip HEAD -- .

Authors

Loupe is written and maintained by Greg Hurrell <[email protected]>.

The original idea for the g:LoupeHighlightGroup feature was taken from Damian Conway's Vim set-up:

Which he discussed in his "More Instantly Better Vim" presentation at OSCON 2013:

History

main (not yet released)

  • Add g:LoupeCaseSettingsAlways to make Vim respect 'ignorecase' and 'smartcase' settings while using star, gstar, # and g#.
  • Ensure that g:LoupeVeryMagic takes effect with longer-forms of the :global, :substitute and :vglobal commands.
  • Treat :g! as equivalent to :v (#20).

1.2.2 (7 August 2018)

  • Fix error-handling to work regardless of 'iskeyword' setting (#14).

1.2.1 (13 July 2016)

  • Match default Vim behavior of opening folds when jumping to a match.

1.2 (27 June 2016)

1.1 (15 June 2016)

  • Make compatible with older versions of Vim that do not have v:hlsearch.
  • Add support for special delimiters with :substitute command.

1.0 (28 December 2015)

0.1 (5 July 2015)

More Repositories

1

command-t

⌨️ Fast file navigation for VIM
Lua
2,707
star
2

wincent

💾 Dot-files
Vim Script
1,110
star
3

ferret

🐀 Enhanced multi-file search for Vim
Vim Script
678
star
4

clipper

✂️ Clipboard access for local and remote tmux sessions
Go
592
star
5

terminus

🖥 Enhanced terminal integration for Vim
Vim Script
452
star
6

vim-university

A curriculum for leveling up your Vim
Shell
242
star
7

scalpel

🔪 Fast within-file word replacement for Vim
Vim Script
110
star
8

corpus

📝 A note-management application
Vim Script
91
star
9

git-cipher

🔐 Tools for storing encrypted content in Git
Ruby
82
star
10

masochist

⛓ Website infrastructure for over-engineers
Hack
79
star
11

vim-clipper

Clipper integration for Vim
Vim Script
40
star
12

wikitext

🌐 Fast wikitext-to-HTML translator
Ruby
34
star
13

vcs-jump

🤾🏻‍♀️ Jump to interesting places with a Git or Mercurial repo
Vim Script
30
star
14

docvim

Documentation generator for Vim plug-ins
Haskell
26
star
15

yak-layout

Yak keyboard layout and optimizer
JavaScript
25
star
16

relay-2-simpler-faster-more-predictable

"Relay 2: simpler, faster, more predictable" presentation given at the Silicon Valley ReactJS Meetup on August 17th, 2016
HTML
21
star
17

base16-nvim

base16 color schemes in Lua for Neovim
Lua
19
star
18

pinnacle

🏔 Highlight group manipulation for Vim
Vim Script
17
star
19

replay

🔁 Convenient re-run of last recorded Vim macro
Vim Script
17
star
20

presentation-template

Simple starting template for slideshow presentations built using reveal.js, highlight.js and HTML
HTML
12
star
21

synergy

Lightweight iTunes controller for Mac OS X
Objective-C
11
star
22

vim-docvim

Syntax highlighting for Docvim comments
Vim Script
11
star
23

passage

🔑 macOS keychain caching proxy
Go
11
star
24

cv

📜 Curriculum vitae
JavaScript
10
star
25

prefnerd

Monitors changes to the OS X defaults database
Ruby
9
star
26

hextrapolate

Number base conversion tool
JavaScript
7
star
27

gerrit-best-practices-tech-talk

Slides from a tech talk at Causes on the subject of best practices for Gerrit code review
CSS
7
star
28

typing-in-js

An introduction to JavaScript type systems
HTML
6
star
29

secure-notes-exporter

🔐 Export Secure Notes from the OS X keychain
C
6
star
30

js

☕️ Assorted JavaScript
TypeScript
5
star
31

Google-Breakpad

Fork of the official Google Breakpad repository
C++
5
star
32

algorithms

Code related to the Princeton Algorithms course
JavaScript
5
star
33

atosym

dSYM-compatible replacement for atos
Objective-C
4
star
34

bansshee

Anti-SSH-attack tool
4
star
35

walrat

Ruby packrat parser generator
Ruby
4
star
36

gdiff

Mac OS X-native diff and patch visualization tool for Git
Objective-C
4
star
37

WinSwitch

Fast User Switching menu replacement for Mac OS X
R
3
star
38

walrus

Object-oriented templating system
Ruby
3
star
39

WOPublic

Common code used in all Wincent products
Objective-C
3
star
40

react-training-week-8

⚛️ Simple exercises for React training week 8
JavaScript
3
star
41

next

To-do app
TypeScript
3
star
42

automatic-octo-barnacle-theme

Empty Liferay 7.1 theme created for testing purposes
CSS
3
star
43

converter

⚛️ Simple demo app for React workshop
JavaScript
3
star
44

remote-component-test

HTML
2
star
45

jost

🤡 Just Jost (not Jest)
JavaScript
2
star
46

url-lengthening-as-a-service

URL lengthener
JavaScript
2
star
47

remote-app-test

JavaScript
2
star
48

presentation

A dead simple presentation boilerplate
JavaScript
2
star
49

wincent-strings-util

Strings file localization tool
Objective-C
2
star
50

login-tool

Command-line tool for managing startup items
Objective-C
2
star
51

clipper-lightning-talk

Lightning talk on Clipper (clipboard access for local and remote tmux sessions)
JavaScript
2
star
52

wopen3

Open3 replacement
Ruby
2
star
53

git-submodules-tech-talk

Slides from a tech talk that I gave at Causes on Git submodules
CSS
2
star
54

buildtools

Build scripts and configuration for use across all Wincent projects
Shell
2
star
55

static-react-boilerplate

Boilerplate for simple static React web applications
JavaScript
2
star
56

wincent-icon-util

Custom folder icon utility
Objective-C
2
star
57

testable-js-lightning-talk

Slides for a lightning talk on writing testable JS and testing it with Jasmine
Ruby
2
star
58

WOHotKey

Hot Key support for Cocoa applications
Objective-C
2
star
59

mkdtemp

Secure creation of temporary directories
Ruby
2
star
60

dented

↔️ Indenting and dedenting utilities
JavaScript
2
star
61

simple-debounce

🏀 Simple debounce implementation that fires on the trailing edge only
JavaScript
2
star
62

rails-3-lightning-talk

Slides for a 5-minute lightning talk on view escaping in Rails 3
JavaScript
2
star
63

unpack-content

🗃 Extract header data and body from plaintext (Markdown-ish) markup source
JavaScript
2
star
64

git-filter-branch-lightning-talk

How to open-source your repo without open-sourcing your repo
CSS
2
star
65

null

An empty value
1
star
66

minimal-npm-boilerplate

Minimal boilerplate for creating an NPM package
JavaScript
1
star
67

fusion

Pure plug-in architecture framework for Objective-C
Objective-C
1
star
68

fusion-base

Base plug-in for building "pure plug-in" apps
Objective-C
1
star
69

fusion-meta

Plug-in management plug-in for building "pure plug-in" apps
Objective-C
1
star
70

fusion-updater

Updater plug-in for building "pure plug-in" apps
C
1
star
71

fusion-crash-reporter

Crash reporter plug-in for building "pure plug-in" apps
C
1
star
72

wincent-on-rails

Legacy Rails application that used to power wincent.com
HTML
1
star
73

askpass

Graphical password prompter
C
1
star
74

compass-lightning-talk

Tiny demo app showing off some features of Compass for a 5-minute lightning talk at Causes
Ruby
1
star
75

conway

Conway's Game of Life
JavaScript
1
star
76

seven-languages-prolog-tech-talk

Slides and code from a tech talk on Prolog given at Causes for our Seven Languages in Seven Weeks reading group
Prolog
1
star
77

tiktoken-ruby

Rust
1
star
78

fusion-demo

Demonstration app for Fusion framework
Objective-C
1
star
79

fusion-menu

Menu plug-in for building "pure plug-in" apps
Objective-C
1
star
80

fusion-help

Help plug-in for building "pure plug-in" apps
C
1
star
81

WOBezel

Bezels, splashes and HUDs for Mac OS X
Objective-C
1
star
82

fusion-prefs

Preferences plug-in for building "pure plug-in" apps
Objective-C
1
star
83

WOTest

Objective-C unit testing framework
Objective-C
1
star
84

gerrit-intro-tech-talk

Slides from an introductory tech talk at Causes on the subject of Gerrit code review
CSS
1
star