1 *loupe.txt* Loupe plug-in for Vim *loupe*
3 CONTENTS *loupe-contents*
6 2. Installation |loupe-installation|
7 3. Mappings |loupe-mappings|
8 4. Options |loupe-options|
9 5. Functions |loupe-functions|
10 6. Overrides |loupe-overrides|
11 7. Related |loupe-related|
12 8. Website |loupe-website|
13 9. License |loupe-license|
14 10. Development |loupe-development|
15 11. Authors |loupe-authors|
16 12. History |loupe-history|
21 a small magnifying glass used by jewelers and watchmakers."
25 Loupe enhances Vim's |search-commands| in four ways:
27 1. Makes the currently selected match easier to see ~
29 When searching using |/|, |?|, |star|, |#|, |n|, |N| or similar, it can be hard to see
30 the "current" match from among all the matches that 'hlsearch' highlights.
31 Loupe makes the currently selected match easier to see by:
33 - Applying a different |:highlight| group (by default, |hl-IncSearch|) to the
34 match under the cursor.
35 - Keeping the matching line centered within the window when jumping between
36 matches with |n| and |N|.
38 2. Applies sane pattern syntax by default ~
40 Loupe makes "very magic" (|/\v|) syntax apply by default when searching. This
41 is true even if you initiate a search via a novel means, such as from a
42 visual selection or with a complicated |:range| prefix.
44 This means that you can use a pattern syntax closer to the familiar regular
45 expression syntax from languages such as Perl, Ruby, JavaScript (indeed,
46 most other modern languages that support regular expressions).
48 3. Provides a shortcut to remove search highlighting ~
50 Loupe maps <leader>n to quickly remove all 'hlsearch' highlighting (although
51 you can provide an alternative mapping of your choosing or suppress the
54 4. Sensible defaults for search-related features ~
56 Loupe provides reasonable defaults for most search-related Vim settings to
57 provide a good "out of the box" experience. For more details, or to see how
58 to override Loupe's settings, see |loupe-overrides|.
60 INSTALLATION *loupe-installation*
62 To install Loupe, use your plug-in management system of choice.
64 If you don't have a "plug-in management system of choice", I recommend
65 Pathogen (https://github.com/tpope/vim-pathogen) due to its simplicity and
66 robustness. Assuming that you have Pathogen installed and configured, and
67 that you want to install Loupe into `~/.vim/bundle`, you can do so with:
69 git clone https://github.com/wincent/loupe.git ~/.vim/bundle/loupe
71 Alternatively, if you use a Git submodule for each Vim plug-in, you could do
72 the following after `cd`-ing into the top-level of your Git superproject:
74 git submodule add https://github.com/wincent/loupe.git ~/vim/bundle/loupe
77 To generate help tags under Pathogen, you can do so from inside Vim with:
79 :call pathogen#helptags()
81 MAPPINGS *loupe-mappings*
84 *<Plug>(LoupeClearHighlight)*
85 Loupe maps <leader>n to |<Plug>(LoupeClearHighlight)|, which clears all
86 visible highlights (like |:nohighlight| does). To use an alternative mapping
87 instead, create a different one in your |.vimrc| instead using |:nmap|:
89 " Instead of <leader>n, use <leader>x.
90 nmap <leader>x <Plug>(LoupeClearHighlight)
92 Note that Loupe will not try to set up its <leader>n mapping if any of the
95 - A mapping for <leader>n already exists.
96 - An alternative mapping for |<Plug>(LoupeClearHighlight)| has already been
97 set up from a |.vimrc|.
98 - The mapping has been suppressed by setting |g:LoupeClearHighlightMap| to 1
102 *<Plug>(LoupeOctothorpe)*
103 Loupe maps |#| to |<Plug>(LoupeOctothorpe)| in order to implement custom
104 highlighting and line-centering for the current match.
106 To prevent this from happening, create an alternate mapping in your |.vimrc|:
108 nmap <Nop> <Plug>(LoupeOctothorpe)
112 Loupe maps |star| to |<Plug>(LoupeStar)| in order to implement custom
113 highlighting and line-centering for the current match.
115 To prevent this from happening, create an alternate mapping in your |.vimrc|:
117 nmap <Nop> <Plug>(LoupeStar)
121 Loupe maps |N| to |<Plug>(LoupeN)| in order to implement custom highlighting and
122 line-centering for the current match.
124 To prevent this from happening, create an alternate mapping in your |.vimrc|:
126 nmap <Nop> <Plug>(LoupeN)
129 *<Plug>(LoupeGOctothorpe)*
130 Loupe maps |g#| to |<Plug>(LoupeGOctothorpe)| in order to implement custom
131 highlighting and line-centering for the current match.
133 To prevent this from happening, create an alternate mapping in your |.vimrc|:
135 nmap <Nop> <Plug>(LoupeGOctothorpe)
139 Loupe maps |gstar| to |<Plug>(LoupeGStar)| in order to implement custom
140 highlighting and line-centering for the current match.
142 To prevent this from happening, create an alternate mapping in your |.vimrc|:
144 nmap <Nop> <Plug>(LoupeGStar)
148 Loupe maps |n| to |<Plug>(Loupen)| in order to implement custom highlighting and
149 line-centering for the current match.
151 To prevent this from happening, create an alternate mapping in your |.vimrc|:
153 nmap <Nop> <Plug>(Loupen)
155 OPTIONS *loupe-options*
158 *g:LoupeHighlightGroup*
159 |g:LoupeHighlightGroup| string (default: IncSearch)
161 Specifies the |:highlight| group used to emphasize the match currently under
162 the cursor for the current search pattern. Defaults to "IncSearch" (ie.
163 |hl-IncSearch|). For example:
165 let g:LoupeHighlightGroup='Error'
167 To prevent any special highlighting from being applied, set this option to
168 "" (ie. the empty string).
172 |g:LoupeLoaded| any (default: none)
174 To prevent Loupe from being loaded, set |g:LoupeLoaded| to any value in your
175 |.vimrc|. For example:
180 *g:LoupeClearHighlightMap*
181 |g:LoupeClearHighlightMap| boolean (default: 1)
183 Controls whether to set up the |<Plug>(LoupeClearHighlight)| mapping. To
184 prevent any mapping from being configured, set to 0:
186 let g:LoupeClearHighlightMap=0
190 |g:LoupeVeryMagic| boolean (default: 1)
192 Controls whether "very magic" pattern syntax (|/\v|) is applied by default. To
195 let g:LoupeVeryMagic=0
198 *g:LoupeCenterResults*
199 |g:LoupeCenterResults| boolean (default: 1)
201 Controls whether the match's line is vertically centered within the window
202 when jumping (via |n|, |N| etc). To disable, set to 0:
204 let g:LoupeCenterResults=0
206 FUNCTIONS *loupe-functions*
211 Apply highlighting to the current search match.
213 OVERRIDES *loupe-overrides*
215 Loupe sets a number of search-related Vim settings to reasonable defaults in
216 order to provide a good "out of the box" experience. The following overrides
217 will be set unless suppressed or overridden (see |loupe-suppress-overrides|):
220 *loupe-history-override*
223 Increased to 1000, to increase the number of previous searches remembered.
224 Note that Loupe only applies this setting if the current value of 'history'
228 *loupe-hlsearch-override*
231 Turned on (when there is a previous search pattern, highlight all its
235 *loupe-incsearch-override*
238 Turned on (while typing a search command, show where the pattern matches, as
239 it was typed so far).
242 *loupe-ignorecase-override*
245 Turned on (to ignore case in search patterns).
248 *loupe-shortmess-override*
251 Adds "s", which suppresses the display of "search hit BOTTOM, continuing at
252 TOP" and "search hit TOP, continuing at BOTTOM" messages.
255 *loupe-smartcase-override*
258 Turned on (overrides 'ignorecase', making the search pattern case-sensitive
259 whenever it containers uppercase characters).
262 *loupe-suppress-overrides*
263 Preventing Loupe overrides from taking effect ~
265 To override any of these choices, you can place overrides in an
266 |after-directory| (ie. `~/.vim/after/plugin/loupe.vim`). For example:
268 " Override Loupe's 'history' setting from 1000 to 10000.
271 " Reset Loupe's 'incsearch' back to Vim default.
274 " Remove unwanted 's' from 'shortmess'.
277 RELATED *loupe-related*
279 Just as Loupe aims to improve the within-file search experience, Ferret does
280 the same for multi-file searching and replacing:
282 - https://github.com/wincent/ferret
284 WEBSITE *loupe-website*
286 The official Loupe source code repo is at:
288 - http://git.wincent.com/loupe.git
292 - https://github.com/wincent/loupe
294 Official releases are listed at:
296 - http://www.vim.org/scripts/script.php?script_id=5215
298 LICENSE *loupe-license*
300 Copyright 2015-present Greg Hurrell. All rights reserved.
302 Redistribution and use in source and binary forms, with or without
303 modification, are permitted provided that the following conditions are met:
305 1. Redistributions of source code must retain the above copyright notice,
306 this list of conditions and the following disclaimer.
308 2. Redistributions in binary form must reproduce the above copyright notice,
309 this list of conditions and the following disclaimer in the documentation
310 and/or other materials provided with the distribution.
312 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
313 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
314 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
315 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
316 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
317 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
318 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
319 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
320 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
321 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
322 POSSIBILITY OF SUCH DAMAGE.
324 DEVELOPMENT *loupe-development*
326 Contributing patches ~
328 Patches can be sent via mail to greg@hurrell.net, or as GitHub pull requests
329 at: https://github.com/wincent/loupe/pulls
331 Cutting a new release ~
333 At the moment the release process is manual:
335 - Perform final sanity checks and manual testing
336 - Update the |loupe-history| section of the documentation
337 - Verify clean work tree:
343 git tag -s -m "$VERSION release" $VERSION
347 git push origin master --follow-tags
348 git push github master --follow-tags
350 - Produce the release archive:
352 git archive -o loupe-$VERSION.zip HEAD -- .
354 - Upload to http://www.vim.org/scripts/script.php?script_id=5215
356 AUTHORS *loupe-authors*
358 Loupe is written and maintained by Greg Hurrell <greg@hurrell.net>.
360 The original idea for the |g:LoupeHighlightGroup| feature was taken from
361 Damian Conway's Vim set-up:
365 https://github.com/thoughtstream/Damian-Conway-s-Vim-Setup/blob/master/plugin/hlnext.vim
367 Which he discussed in his "More Instantly Better Vim" presentation at OSCON
370 - https://www.youtube.com/watch?v=aHm36-na4-4
372 HISTORY *loupe-history*
376 - Make compatible with older versions of Vim that do not have |v:hlsearch|.
377 - Add support for special delimiters with |:substitute| command.
379 1.0 (28 December 2015) ~
381 - Renamed the |<Plug>LoupeClearHighlight| mapping to
382 |<Plug>(LoupeClearHighlight)|.
386 - Initial release, extracted from my dotfiles
387 (https://github.com/wincent/wincent).