sponsor Vim development Vim logo Vim Book Ad

betterSearch.vim : Provide better search functionality by capturing all matched line

 script karma  Rating 6/3, Downloaded by 146    Comments, bugs, improvements  Vim wiki

created by
kn n
 
script type
utility
 
description
** note: currently the script is tested in MS window environment using GVIM **
** note: BetterSearchVisualSelect command is found not to be working at the moment **

Features offered by betterSearch:
- This script is written to copy all the search result and put it to window above the content.
- If the line number is switch on, the search result is 'jumpable' to the content window by just enter on that particular search line
- Search term highlight can be switched on and off
- Search keyword can be saved to clipboard

There are a few way to use the function of this script.
[ usage 1 ]  
User intended to type in the search words
:BetterSearchPromptOn
then <ENTER>.
A window will pop up for user input.
The user input can consists of more than one search term. For example: search_A|search_B|search_C...

[ usage 2 ]
User intended to use the word under the cursor as the search term
:BetterSearchPromptOn    
then <ENTER>. and press <ENTER> again when the user input dialog box appear without type in any word

[ usage 3 ]
User intended to user the word highlighted in visual mode
:BetterSearchVisualSelect
then <ENTER>.

[ jump to line ]
A search window will be open up on top of the current window.
Press <ENTER> on that particular line to jump to the content window.

[ other commands ]
Other command available by the script.
':BetterSearchSwitchWin'        - to switch between the 'Search Window' and the 'Content Window'
':BetterSearchVisualSelect'     - to search based on the visually selected word
':BetterSearchHighlighToggle'   - to toggle keyword highlight on off (default is on)
':BetterSearchHighlightLimit'    - to toggle line limit to switch off keyword highlight, for efficiency purpose,
                               - especially for large matched, default is 5000 line
':BetterSearchCopyToClipBoard' - to toggle whether to save to the search words to clipboard, default is off

[ mapping ]
Suggest to map following in .vimrc, e.g:
nnoremap <A-S-F7> :BetterSearchPromptOn<CR>
vnoremap <A-S-F7> :BetterSearchVisualSelect<CR>
nnoremap <A-w>  :BetterSearchSwitchWin<CR>
nnoremap <A-S-q>  :BetterSearchCloseWin<CR>
 
install details
1. Paste the betterSearch.vim script into Vim\vim73\plugin.
2. Restart the Vim session
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
betterSearch.vim 0.0.4 2013-01-03 7.0 kn n - enhanced help description
betterSearch.vim 0.0.3 2013-01-03 7.0 kn n - showed the file path
- added function to close the bettersearch window from anywhere
- fixed visual select search
betterSearch.vim 0.0.2 2012-10-01 7.0 kn n - able to set highlight syntax for search term
- change default shortcut for syntax=c, help=F1
- improve help description
betterSearch.vim 0.0.1 2012-09-27 7.0 kn n Initial upload
ip used for rating: 23.20.196.179

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo