- Notifications
You must be signed in to change notification settings - Fork0
salsifis/vim-codesearch
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a vim plugin that helps you interact withCodeSearch.
The goal is to index the contents of all source files within a working directory, and therefore being ableto run instantaneous search queries.
If you have the Pathogen plugin installed or any other plugin manager, thenjust copy this filetree into a subfolder of your Bundle folder.
The use of this plugin requires the binaries ofCodeSearch.Usego get github.com/junkblocker/codesearch/cmd/... to build them.
Prior to using the plugin you need to know:
- Where your source files are located
- What command can list the files to index
- Where csearch and cindex binaries are stored
Example with the sources of SQLite:
Checkout sources using fossil:
cd /tmp && mkdir SQLite && cd SQLitefossil clone https://sqlite.org/src bare_repositorymkdir indexmkdir worktree && cd worktree && fossil open ../bare_repository
Declare your index. You need four arguments:
- Storage directory for the index
- Directory for your worktree
- Command listing files when inside the worktree
- Directory for the csearch and cindex binaries
:call codesearchindex#declareindex('/tmp/index', '/tmp/SQLite/worktree', 'fossil ls', '/opt/codesearch/bin')or:
:DeclareIndex /tmp/index /tmp/SQLite/worktree fossil\ ls /opt/codesearch/binYou can make helpers for this command when you intend to work on SQLite.
Run a first-time indexation:
:MkIndexPerform a search:
:SearchExprInIndex write.*pageFill your clipboard with “as follows:”, then use
:SearchFromRegisterInIndex +(if your + register is associated with clipboard)
I use (among others) the following mappings:
" Use F2 for case-sensitive search, F3 for case-insensitive search" F2 or F3 on a word: word lookup in index" F2 or F3 in visual mode: lookup for highlighted text" Shift-F2 or Shift-F3: lookup for text in clipboardnnoremap <F2> :SearchWordInIndex <C-R><C-W><Return>nnoremap <F3> :SearchWordInIndex! <C-R><C-W><Return>xnoremap <F2> "zy:SearchFromRegisterInIndex z<Return>xnoremap <F3> "zy:SearchFromRegisterInIndex! z<Return>nnoremap <S-F2> :SearchFromRegisterInIndex +<Return>nnoremap <S-F3> :SearchFromRegisterInIndex! +<Return>The main git repository for this plugin is athttp://github.com/salsifis/vim-codesearchindex
zlib/libpng license.
Copyright (c) 2020 Benoit Mortgat
This software is provided 'as-is', without any express or implied warranty. Inno event will the authors be held liable for any damages arising from the useof this software.
Permission is granted to anyone to use this software for any purpose, includingcommercial applications, and to alter it and redistribute it freely, subject tothe following restrictions:
The origin of this software must not be misrepresented; you must not claimthat you wrote the original software. If you use this software in a product,an acknowledgment in the product documentation would be appreciated but is notrequired.
Altered source versions must be plainly marked as such, and must not bemisrepresented as being the original software.
This notice may not be removed or altered from any source distribution.
About
Resources
Uh oh!
There was an error while loading.Please reload this page.