tomrijndorp / vscode-finditfaster

Find it, but faster! Fast file search for VS Code.
MIT License
254 stars 25 forks source link
fzf ripgrep vscode vscode-extension

FindItFaster

CI pipeline - release Platform support

Finds files and text within files, but faster than VS Code normally does.

Make sure to check the Requirements below (TL;DR: have fzf, rg, bat on your PATH).


Default key bindings:

You can change these using VS Code's keyboard shortcuts.

Recommended settings:


Native Windows support is now implemented (experimental)! Also see Known Issues.


Features

This plugin is useful if you deal with very large projects with lots of files (which makes VS Code's search functionality quite slow), or when you simply love using fzf and rg and would like to bring those tools inside VS Code, similar to how the excellent fzf.vim plugin works for Vim.

This extension exposes four commands:

  1. Search for files and open them. Uses a combination of fzf, rg, and bat.
  2. Search within files for text and open them. Uses a combination of fzf, rg, and bat.
  3. Like 2., but you can limit the file types that will be searched.
  4. Resume search. Repeats the last run command with the previous query prepopulated.

If your active text editor has a selection, it will be used as the initial query (you can disable this setting).

⬇️  Find files
Find Files

⬇️  Find text within files
Find Within Files

⬇️  Find text within files, with file type filter
Find Within Files

This extension has also been tested on remote workspaces (e.g. SSH sessions).


Requirements

This plugin opens a terminal inside VS Code. Make sure that you can run fzf, rg, bat, and sed by running these commands directly in your terminal. If those work, this plugin will work as expected. If it doesn't, confirm that you are running recent versions of all three tools.

If you're not familiar with these command line tools, you might want to check them out. They are awesome tools that can be individually used and make you more productive. And when combined such as for instance in this extension, they're very powerful. They're available for many platforms and easy to install using package managers or by simply installing a binary.

I have no affiliation with any of these tools, but hugely appreciate them, and wanted to bring them into a VS Code context.


Extension Settings

See the settings for this extension in the GUI.
You might want to play with fzf, rg and bat on the command line and read their manuals in order to get a better understanding of some of the settings in this extension. It will be worth your time.

fzf can also be configured through various environment variables. This extension does nothing to disable that behavior, so feel free to use those. You can also check whether fzf is running inside this extension by checking whether the FIND_IT_FASTER_ACTIVE environment variable is set.


Known Issues

Windows. There are two ways of running this extension on Windows:

  1. Natively using Powershell. This feature was added as of May 2022 and is experimental at this stage. Please file an issue on Github if you find one.
  2. Through WSL (Windows Subsystem for Linux). You can run this extension inside a Remote-WSL workspace.

Not tested on Docker / Github code spaces. Will likely work without issues as the functionality is very similiar to other remote sessions (e.g. SSH, WSL).

Various small terminal issues. VS Code gives developers little control over the terminal. We can't know if you typed text into the terminal we create, so that might interfere with the extension. There are various subtle ways in which in which things can break, many of which can't be detected. That said, if you don't touch the FindItFaster terminal, things should work well!

NixOS:

The bash scripts use a shebang that conflicts with NixOs: #!/bin/bash , as bash isn't available in /bin, a work around is to this to follow the instructions in Issue #44 and change the shebangs manually, after this, the extention should work normally.


FAQ

🕹 How do I control the fuzzy finder view?

➥ Whatever defaults are present on your system (and read by VS Code) are used. For fzf, this means <Ctrl+K> moves the selection up, <Ctrl+J> moves down, and <Enter> selects. You can also use the up and down arrows if that's your thing. <TAB> for multiple select when available. Read the excellent fzf documentation to learn more about using fzf.

⬆️ I'm on Linux and I can't use Ctrl+K to navigate upwards in fzf.

➥ Probably VS Code is waiting for you to complete a multi-step keyboard shortcut (chord). Change the following setting in your preferences to disable chords:

  "terminal.integrated.allowChords": false

🔍 There's a file that cannot be found / searched through?

➥ This extension enables you to search through multiple directories: the process working directory, the workspace directories, and any additional directories you specify in the extension settings. What paths are included is configured through the settings. There's a listSearchLocations command that can show you which paths are currently being indexed.

🧘 Can you give focus back to my editor / my problems panel / other?

➥ I don't the VS Code API enables me to do this. Shoot me a message if you think I'm mistaken and I'll try to make this better.
2023 Update: Added a setting find-it-faster.general.killTerminalAfterUse. When true, it will kill the extension's terminal which may result in VS Code focusing the previous one. It may help you.
2024 Update: I recommend using find-it-faster.general.useTerminalInEditor. This way, the extension window won't interfere with your other terminals, and you get more real estate for previewing files.

🐞 I found a bug!

➥ Yeah, that's not unlikely. There are a lot of edge cases with this sort of tooling. Three options:

  1. Shrug :)
  2. File a Github issue. Please give detailed information as the devil is in the details. Please provide at least:
    • OS
    • VS Code version
    • Does it happen after you reset to default settings (if relevant)?
    • Anything special about your configuration / workspace. Did you have spaces in there? Is it on a network share or some other thing I definitely didn't test? Did you modify the extension settings?
  3. For the most up to date information on contributing fixes and features, see CONTRIBUTING.md.

💩 I don't like fzf / rg / bat. Can I just use find, grep, and cat or something else?

➥ You can actually already use other preview tools than bat, e.g. cat. I've left some hints in the settings. Outside of what's available, substituting other tools is not supported.

💲 Can I set FZF env vars that only work within this extension?

➥ You can, by adding something like this to ~/.bashrc or whatever configures your enviroment:

if [[ $FIND_IT_FASTER_ACTIVE -eq 1 ]]; then
  FZF_DEFAULT_OPTS='--height=50%'
fi

🪚 Can I build in a feature myself / contribute in some way?

➥ For the most up to date information on contributing fixes and features, see CONTRIBUTING.md.

🤑 Do you take donations?

➥ Thanks for asking, but no. The amount of work that went into this extension is tiny compared to the countless hours that have gone into the command line tools that are leveraged in this extension. Please support those tools instead.
What I do appreciate is if you'd help others find this extension by spreading the word and/or leaving a rating!


Release Notes

0.0.38

0.0.37 (broken)

0.0.36

0.0.35

0.0.34

0.0.33

0.0.32

0.0.31

0.0.30

0.0.29

0.0.28

0.0.27

0.0.26

0.0.25

0.0.24

0.0.023

0.0.22

0.0.21

0.0.20

0.0.19

0.0.18

0.0.17

0.0.16

0.0.15

0.0.14

0.0.13

0.0.12

0.0.11

0.0.10

0.0.9

0.0.7

0.0.6

0.0.3

0.0.2

0.0.1

You gotta start somewhere!

Tested on these configurations:

Mac OS:

OS         : Darwin 20.1.0 (MacOS Big Sur 11.0.1)
bat version: bat 0.18.0
fzf version: 0.27.1 (brew)
rg version : ripgrep 13.0.0

Linux:

OS         : Linux 5.8.0-55-generic (Ubuntu 20.04)
bat version: bat 0.12.1
fzf version: 0.20.0
rg version : ripgrep 12.1.1 (rev 7cb211378a)