YetAnotherCodeSearch
SublimeText 3 plugin fo working with CodeSearch
Details
Installs
- Total 631
- Win 296
- Mac 169
- Linux 166
Dec 30 | Dec 29 | Dec 28 | Dec 27 | Dec 26 | Dec 25 | Dec 24 | Dec 23 | Dec 22 | Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
YetAnotherCodeSearch
This is a plugin for Sublime Text 3 that works with CodeSearch to provide fast searching in a large codebase. This is most useful for large projects where a normal Find is just too slow.
Yet Another…?
Yeah. There is SublimeCodeSearch; however, there is no LICENSE file so I couldn't make any modifications to the project. That said, this project will probably deviate enough from SublimeCodeSearch that it will be worth separating anyway. Some things worth highlighting:
- Search results are placed in a buffer, similar to Sublime Text's Find functionality.
- Searching and indexing don't require a
csearchindex
setting to be set in the project, thus using the user's index file, as is the default forcindex
. - Plus new features
- Can specify case and file restrictions when searching
- Manage and update the index file for a Sublime project.
Setup
Prerequisite
You will need a CodeSearch binary. You can build this by installing Go and get the binary.
go get github.com/google/codesearch/cmd/...
Installation
The easiest way to install the plugin is to simply use PackageControl. Just look for the YetAnotherCodeSearch plugin and install.
-or-
You could download/clone the source and place it into your Sublime Text plugin directory with the name YetAnotherCodeSearch.
git clone \
https://github.com/pope/SublimeYetAnotherCodeSearch.git \
YetAnotherCodeSearch
Usage
As is with CodeSearch, there are two main steps to using this plugin - indexing and searching.
Indexing
In order to make searching fast, first we need to index the project. To do that, open up the command palette (Tools > Command Palette…) and look for Code Search Index. This command runs in the background and could take a while depending on the size of the project and the speed of the disk.
That works with existing index files, but YetAnotherCodeSearch can also set up
an index for your current project. From the command palette, run
Code Search Index Project. What this will do is take all of the folders in the
project and index them for you. For this to work though, you must specify a
project csearchindex
file. See Project Settings above.
It should be noted, if you make edits to files then you will want to re-run the indexing step as to pick up those edits for the next time you run a search.
Searching
To run a search, open up the command pallet (Tools > Command Palette…) and look for Code Search. This will open up an input for you to enter your query.
From there, enter a regex-based search query. Multiple queries are supported. Each term will be ORed together. For queries with spaces in them, you can either escape the spaces or wrap the query in quotes.
Here are some examples:
some_obscure_method
my_method my_variable
"Hello, world"
The csearch
command also supports limiting the results to just files that
match a regex as well as can be told to be case insensitive. Since Sublime
doesn't allow you to set custom UI on the input bar, you can encode these
properties into special keywords in the query – namely file:
and case:
.
some.*variable.*name case:no
my_method file:\.py$
foo.*bar case:NO file:\.[ch]$
Once you enter your query, the Code Search Results file view should come into
focus. You can move to any matched line and then press the enter
key and be
taken to that file and that match. You can also invoke the Goto Symbol command
(Goto > Goto Symbol…) to get a list of all of the files that match your
query.
Settings
In case anyone is migrating over from SublimeCodeSearch (like myself), you will be pleased to know that the settings and setting names are the same for this plugin.
The location of csearch
and cindex
can be specified by editing the user-
specific YetAnotherCodeSearch.sublime-settings
file. See the default file
for configuration options. Both are easily found via
Preferences > Package Settings > YetAnotherCodeSearch.
To add keyboard shortcut open Preferences > Key Bindings - User and add
something like { "keys": ["alt+ctrl+shift+f"], "command": "csearch" }
.
Project Settings
You can specify an index file to use for the project by editing the project (Project > Edit Project) and adding the following property to the JSON file.
"code_search": {
"csearchindex": "path/to/csearchindex"
}
The location of codesearchindex
is defined relatively to the project location.
Development
Please file an issue if you would like a new enhancement of if you run into any bugs. Of course, patches are always welcome :)
Testing
In order to run the unit tests, please install randy3k's lovely UnitTesting Sublime plugin and run the unit tests via that.