Coder Social home page Coder Social logo

searchinproject_sublimetext's Introduction

Project is discontinued!

I'm not using Sublime Text anymore and have no interest in supporting this project.

I added the MIT license to be explicit, so if you want to carry one, you have my full permission - and gratitude!

Search In Project

Search in Project screencast

This plugin for Sublime Text 2 and 3 lets you use your favorite search tool (grep, ack, ag, pt, rg, git grep, or findstr) to find strings aross your entire current Sublime Text project.

It opens a quick selection panel to browse results, and highlights matches inside files.

Usage

  • Use the key binding (⌘⌥⇧F on OS X, Ctrl+Alt+Shift+F on Windows and Linux), or
  • Call the "SearchInProject: Search" command;
  • Enter the search query;
  • Hit Enter (Return). You'll be presented with a "quick select" panel with the search results. Select any file from that panel (it supports fuzzy searching) to go to the match. The search string will be highlighted with an outline and a circle symbol in the gutter area.
  • The last item on the quick select panel is "List results in view". Pick it to see results in a regular editor view. (Tip: if you enter three ticks ("`") in the search box - it's going to be to be the first item.)

If you select text and run Search In Project, the program will pre-fill the search string with the selection text. For an example, to search for a word project-wide, press the following buttons: ⌘D, ⌘⌥⇧F, ↩.

If you run Search In Project again, the program will remember the last search string, so the next search will be an ↩ away.

Important note for Windows users: the current release has known issues with running executables, and I would appreciate any bug reports from the field.

Installation

Package Control: install package Search in Project (this is the recommended method)

Manual installation: download an archive of the repository, and unzip into the Sublime Text Packages folder.

Installing search engines

My idea is that if you use this plugin it's because you already use one of the superior search engines like The Silver Searcher and want to use it from within Sublime Text.

The supported search engines are:

Name Description Search in Project key
pt (The Platinum Searcher) fast, has binaries for every platform, recommended. the_platinum_searcher
ag (The Silver Searcher) equally fast, only 3rd party binaries for Windows, also recommended the_silver_searcher
ack not as fast as pt and ag, but still pretty good. Depends on perl, thus not so easy to install on Windows. ack
git grep packaged with Git and really fast, but only works in Git repositories. Recommended if you use Windows and Git and really don't want to install anything else. git_grep
grep fallback search tool available on Linux and OSX systems. Not recommended - just use the built-in Sublime Text search instead. grep
findstr fallback search tool available on Windows. Not recommended - just use the built-in Sublime Text search instead. find_str

You need to choose the engine that you want to use in the configuration file. The default is the one that available on every system, but it is easily the worst.

Configuration

Configuration is stored in a separate, user-specific SearchInProject.sublime-settings file. See the default file for configuration options; links to both could be found in the main menu in Preferences -> Package Settings -> Search In Project.

Issues with locating executables

If Search In Project has problems with locating executables in Mac, install the Fix Mac Path plugin.

You can always configure the full path to any search engine in the settings, as a catch-all solution.


Made by Leonid Shevtsov

searchinproject_sublimetext's People

Contributors

ahuff44 avatar apfelchips avatar cmptadam avatar henrahmagix avatar keimlink avatar kojoru avatar leonid-shevtsov avatar martinfinke avatar pstadler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

searchinproject_sublimetext's Issues

Document preview

SublimeText has a preview of files when using cmd+p, maybe there is a way to do that on your results

The plugin regularly freeze ST3

I always encounter with ST3 freeze after using the plugin to search.
I need to open and close ST3 then using the plugin (find the ST3 freeze) and close ST3 maybe 3-4 times before I able to use the plugin normally. I need to do this every time after I turn on PC.

P.S. I use the plugin with Silver searcher on Debian9.

Find results in a buffer

It would be nice to have the search results in a buffer or a window instead of a dialog. One can go back to the window and open several search results that way. Similar to the built in "Find in files..." command.

auto-detect .git in sub-folder project

If I use 'git_grep' as search engine, it will works only if sublime project path point to a directory with ".git" .

Should be great if it could auto-detect .git directory in project sub-folders .

on windows, can't use the silver searcher engine

I use sublime 3 and SearchInProject plugin on windows.
I am sure I have installed the ag.exe with choco and also on msys2.
But when I search something with SearcherInProject , I got some error like as follows:

default

Any idea about how can I make it work?
In README you mentioned "You can always configure the full path to any search engine in the settings, as a catch-all solution.", how should I do this?

Menu paths

Main.sublime-menu specifies the package directory as ${packages}/SearchInProject, but the package was installed by Package Control to ${packages}/Search in Project, so three of the menu items (README, Settings – Default, Key Bindings – Default) don't work.

suggestion: configuration entry "show_results_mode"

As a suggestion, it could have a configuration entry with the following specs:

entry: "show_results_mode"
options: ['list', 'all']

Description:
'list' => show result as list with file names (default)
'all' => show all result in new tab (like list results in view)

Select previous search keyword

Great plugin!

Input panel shows previously entered keyword. It would be nice if the keyword is selected (like core's Replace), so you can start typing new keyword without having to delete existing one.

Thanks.

Path separator missing (MacOS 10.13.3)

When I search with ag, I get, for example
prince/samples/DebugEvaluate.xhtml
2:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"

When I search from Sublime Text, using ag, I get
/UsersbarryprincemozillaprincesamplesDebugEvaluate.xhtml:
2:51: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"

The path separators have been gobbled, and so the links are invalid. Am I missing a preference setting?

Exclude file types

It does not exclude file types which is excluded by project. Ex: svn files, cscope etc.

Is there an explicit configuration for that ?

Thanks,
Akhil

ripgrep engine support not mentioned in all places

  • SearchInProject.sublime-settings (in the list at the top, as ripreg, not as rg)
  • Top of readme in the brief list of supported engines
  • Bottom of readme.txt (github default page), with instructions and descriptions for each engine
  • List of engines in Package Control Messages after install (install.txt)

Might want to check other engines too

(This is important because it wasn't clear to me the correct value for search_in_project_engine was "ripgrep", not "rg", and I thought maybe the inclusion of ripgrep might have been a typo since it was mentioned in so few places)

problem with the silver searcher

I have a problem searching with silver searcher. Invoking ag from the plugin his detect that stdin is a pipe and disable the print of line number on the result (see line 177 and 378 on options.c of ag source).
Tested with last ag compiled from source, on osx 10.8

Use Quoted Paths

Hello! Thank you for the plugin! :) It's not working with paths that contain spaces, though...You just have to modify the method search_folders in your search_in_project.py: (Sorry the indentation is broken but you figure it out)

def search_folders(self):
window_folders = self.window.folders()
for index, item in enumerate(window_folders):
window_folders[index] = """ + window_folders[index] + """
file_dirname = [""" + os.path.dirname(self.window.active_view().file_name()) + """]
return window_folders or file_dirname

This will pass the quoted path to the executable, but it breaks the plugin in other places...Can you please fix this? :)

Unsaved documents are not searched

Consider a project with only one document doc.txt:

some text written here

which has been modified to—but not saved:

some unsaved text written here

then searching for unsaved will return no results.

Caveat: I'm unsure if this is desired behavior.

Tag new version

Looks like there has been quite a few commits since the last version tag. Can a new tag be created so that Package Control picks it up? Otherwise, you have to clone the repo to get the latest code

Results in a document

Can I have the results in a new document like the default search of Sublime?

Tank you

Opens new file with title "D"

When I'm using Search In Project with pt on Windows, Sublime creates a new file when I try to open a file from the quick select menu.

image

image

Only have pt in my user settings

RuntimeError running search engine find_str

I got an error when using it in Sublime3 on Windows 10.

RuntimeError running search engine find_str:
FINDSTR: Cannot open lib\?

This is my Preferences.sublime-settings---User file:

{
    "color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
    "font_face": "Segoe Condensed",
    "font_size": 15,
    "search_in_project_engine": "the_silver_searcher",
    "ignored_packages":
    [
    ],
    "vintageous_use_ctrl_keys": true
}

I've installed ag on my computer, I can directly use ag in Command Prompt. So I don't know why it tried to use find_str.

ImportError: No module named 'searchengines.ag

I just installed this package in ST3 on Mac Build 3143
Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 797, in run_ return self.run() File "/Users/alex/Library/Application Support/Sublime Text 3/Packages/Search in Project/search_in_project.py", line 46, in run __import__("searchengines.%s" % self.engine_name) ImportError: No module named 'searchengines.ag'

does not work in ST2

console shows right command, like
Running: ag --column --search-files --nogroup --nocolor four_letter_word "/xox/www/current_local"
(if I run this command in bash everything works: many results)

but in SublimeText2 it just opens "no result" combo :( .

Env: MacOs 10.8.5
SublimeText2
SearchInProject installed by recommended method
settings User is changed to:
"search_in_project_engine": "the_silver_searcher",

ripgrep + windows platform

Hi, a few issues on windows + ripgrep

  1. output from ripgrep on windows, file path has ":" in directory name. ie: "E:\Data\XXX"
    It breaks _parse_output function

  2. path separator of windows is "" instead of "/", it breaks find_common_path and other path joining

    def _parse_output(self, output):
        lines = output.split("\n")
        line_parts = [line.split(":", 3) if Base.HAS_COLUMN_INFO.match(line) else line.split(":", 2) for line in lines]

    def find_common_path(self, paths):
        paths = [path.replace("\"", "") for path in paths]
        paths = [path.split("/") for path in paths]

Memory issue when using The Silver Surfer / ag in ST3 on OSX

Thanks for this plugin. It's very helpful. I noticed an issue while searching through a directory that has some large files in it using The Silver Surfer in OS X 10.12.6.

RuntimeError running search engine the_silver_searcher:
ERR: expected to read 756594091 bytes but read 4294967295

From this discussion, it seems to be related to the mmap defaults in OS X
ggreer/the_silver_searcher#1038

The solution was to add a --mmap option to the mandatory_options. I did that and it's working for me.

Not sure if that has other implications. You might want just add a comment to the default configuration if so.

Hope that helps.

-Paul

ST3 support?

This looks nice. Have you been considering Sublime Text 3 support?

use zsh instead of bash

Hi, when I do a search using Ag, I get an error that it is not found in bin/bash. I am using zsh, can this be changed to look in zsh instead of bash?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.