swiper
Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
Top Related Projects
:cherry_blossom: A command-line fuzzy finder
Find, Filter, Preview, Pick. All lua, all the time.
Fuzzy Finder in rust!
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
A simple, fast and user-friendly alternative to 'find'
An interactive cheatsheet tool for the command-line
Quick Overview
Swiper is a collection of Emacs packages designed to enhance the search and navigation experience within Emacs. It provides a modern, efficient, and visually appealing interface for various search-related tasks, including buffer switching, file navigation, and in-file text search.
Pros
- Improves search efficiency and speed in Emacs
- Offers a clean and intuitive user interface
- Highly customizable and extensible
- Integrates well with other Emacs packages and workflows
Cons
- May have a learning curve for users new to Emacs or advanced search techniques
- Can be resource-intensive on larger projects or with many open buffers
- Some users may find the default keybindings conflicting with their existing setup
- Requires initial configuration to get the most out of its features
Code Examples
- Basic Ivy completion:
(ivy-read "Choose a fruit: " '("Apple" "Banana" "Cherry" "Date")
:action (lambda (fruit) (message "You chose %s" fruit)))
This code prompts the user to choose a fruit using Ivy completion.
- Swiper search in current buffer:
(swiper "search term")
This initiates a Swiper search for "search term" in the current buffer.
- Counsel-find-file for file navigation:
(counsel-find-file)
This opens the Counsel interface for finding and opening files.
Getting Started
To get started with Swiper, add the following to your Emacs configuration:
(use-package swiper
:ensure t
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
:bind (("C-s" . swiper)
("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)))
This configuration enables Ivy mode, sets up some basic options, and binds common Swiper functions to convenient key combinations.
Competitor Comparisons
:cherry_blossom: A command-line fuzzy finder
Pros of fzf
- Language-agnostic and can be used in various environments (shell, vim, etc.)
- Faster performance, especially for large datasets
- More flexible and customizable with a wide range of options
Cons of fzf
- Requires separate installation and setup
- Less integrated with Emacs ecosystem
- Steeper learning curve for advanced features
Code Comparison
fzf:
find * -type f | fzf > selected
swiper:
(swiper)
fzf focuses on providing a general-purpose fuzzy finder that can be integrated into various tools and workflows. It excels in performance and flexibility but requires more setup.
swiper is specifically designed for Emacs and offers seamless integration with the editor. It provides a more streamlined experience for Emacs users but may not be as versatile outside of that environment.
Both tools aim to improve search and navigation, but they cater to different use cases and preferences. fzf is better suited for users who work across multiple environments and need a powerful, customizable fuzzy finder. swiper is ideal for Emacs enthusiasts who want a tightly integrated and easy-to-use search solution within their preferred editor.
Find, Filter, Preview, Pick. All lua, all the time.
Pros of telescope.nvim
- Built specifically for Neovim, offering deeper integration and better performance
- Highly extensible with a rich ecosystem of plugins and extensions
- Supports asynchronous searching, providing faster results for large codebases
Cons of telescope.nvim
- Limited to Neovim users, not available for other editors or Vim
- Steeper learning curve due to its extensive configuration options
- Requires Lua knowledge for advanced customization
Code Comparison
telescope.nvim:
require('telescope').setup{
defaults = {
mappings = {
i = {
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
},
},
}
}
swiper:
(use-package swiper
:ensure t
:config
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume))
Both projects aim to enhance search functionality, but telescope.nvim is more focused on Neovim-specific features and extensibility, while swiper provides a simpler, more universal solution for Emacs users. telescope.nvim offers more advanced features at the cost of complexity, while swiper prioritizes ease of use and broader compatibility.
Fuzzy Finder in rust!
Pros of skim
- Written in Rust, offering potential performance benefits
- Cross-platform support (Linux, macOS, Windows)
- Can be used as a standalone CLI tool, not tied to a specific editor
Cons of skim
- Smaller community and ecosystem compared to swiper
- Less integrated with Emacs-specific features
- Fewer customization options for Emacs users
Code comparison
skim (Rust):
pub fn main() {
let options = SkimOptionsBuilder::default()
.height(Some("50%"))
.multi(true)
.build()
.unwrap();
Skim::run_with(&options, None)
.map(|out| out.selected_items)
.unwrap_or_else(|| Vec::new())
}
swiper (Emacs Lisp):
(defun swiper ()
(interactive)
(let ((candidates (swiper--candidates)))
(ivy-read "Swiper: " candidates
:initial-input (swiper--initial-input)
:action #'swiper--action
:re-builder #'swiper--re-builder
:history 'swiper-history
:caller 'swiper)))
The code snippets showcase the different approaches and languages used by skim (Rust) and swiper (Emacs Lisp). skim focuses on standalone functionality, while swiper is tightly integrated with Emacs and Ivy.
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Pros of ripgrep
- Extremely fast search performance, especially for large codebases
- Supports searching with regular expressions and Unicode
- Automatically respects gitignore rules and hidden files
Cons of ripgrep
- Command-line tool, lacks interactive UI for browsing results
- Not integrated with text editors or IDEs out of the box
- Limited to searching file contents, doesn't provide advanced filtering options
Code Comparison
ripgrep:
rg "pattern" /path/to/search
swiper:
(swiper "pattern")
Summary
ripgrep is a powerful command-line search tool focused on speed and efficiency, while swiper is an Emacs package that provides interactive search capabilities within buffers. ripgrep excels at searching large codebases quickly, but lacks the interactive UI and editor integration that swiper offers. swiper, on the other hand, provides a more user-friendly interface for searching and navigating within Emacs, but may not be as fast for searching across multiple files or large projects. The choice between the two depends on the specific use case and preferred development environment.
A simple, fast and user-friendly alternative to 'find'
Pros of fd
- Written in Rust, offering better performance and memory safety
- Simpler syntax and easier to use for basic file searching tasks
- Colorized output and smart case sensitivity by default
Cons of fd
- More limited in scope, focusing primarily on file searching
- Lacks advanced text searching capabilities within files
- Not as deeply integrated with Emacs ecosystem
Code Comparison
fd:
fd pattern
swiper:
(swiper "pattern")
Summary
fd and swiper serve different purposes and target different user bases. fd is a command-line tool for efficient file searching, while swiper is an Emacs package for interactive searching and navigation within buffers.
fd excels in simplicity and performance for file system searches, making it ideal for quick command-line use. Its Rust implementation provides speed and safety advantages.
swiper, on the other hand, offers powerful text searching capabilities within Emacs, integrating seamlessly with the editor's ecosystem. It provides a more comprehensive solution for text editing and navigation tasks.
The choice between the two depends on the user's needs: fd for quick file searches in the terminal, and swiper for advanced text searching and navigation within Emacs.
An interactive cheatsheet tool for the command-line
Pros of navi
- Focuses on command-line productivity with interactive cheatsheets
- Supports multiple shells and integrates with existing command-line tools
- Allows for easy sharing and customization of cheatsheets
Cons of navi
- More specialized tool compared to Swiper's broader text navigation capabilities
- Steeper learning curve for creating and managing cheatsheets
- Limited to command-line use, while Swiper works in various Emacs contexts
Code comparison
navi:
navi --print "git commit"
Swiper:
(ivy-read "Search: " (buffer-string)
:action (lambda (x)
(goto-char (cdr x))))
Key differences
Navi is a command-line tool for managing and accessing cheatsheets, while Swiper is an Emacs package for incremental searching and text navigation. Navi excels in providing quick access to command-line snippets and workflows, whereas Swiper offers powerful search capabilities within Emacs buffers.
Navi's strength lies in its ability to create, share, and use interactive cheatsheets across different shells and environments. Swiper, on the other hand, provides a more general-purpose text navigation solution within the Emacs ecosystem, offering features like fuzzy matching and flexible actions on search results.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Flexible, simple tools for minibuffer completion in Emacs
This repository contains:
-
Ivy, a generic completion mechanism for Emacs.
-
Counsel, a collection of Ivy-enhanced versions of common Emacs commands.
-
Swiper, an Ivy-enhanced alternative to Isearch.
Ivy
Ivy is a generic completion mechanism for Emacs. While it operates
similarly to other completion schemes such as icomplete-mode
, Ivy
aims to be more efficient, smaller, simpler, and smoother to use yet
highly customizable.
To try Ivy, just call M-x ivy-mode
. This will enable
generic Ivy completion, including specific completion for file and
buffer names.
Installation
Install the ivy
package from GNU ELPA or MELPA.
Users of Debian â¥10 (and derivatives such as Ubuntu â¥18.04) can
install Ivy, Counsel, and Swiper with sudo apt install elpa-counsel
.
To add Hydra support: sudo apt install elpa-ivy-hydra
.
Documentation
Manual
Installing ivy
from GNU ELPA or MELPA also installs the manual under
the (ivy)
Info node.
The source file for the Info manual is ivy.org
.
The manual is also available as HTML.
Wiki
There is an Ivy and Swiper wiki on GitHub.
Small config example
(ivy-mode)
(setopt ivy-use-virtual-buffers t)
(setopt enable-recursive-minibuffers t)
;; Enable this if you want `swiper' to use it:
;; (setopt search-default-mode #'char-fold-to-regexp)
(keymap-global-set "C-s" #'swiper-isearch)
(keymap-global-set "C-c C-r" #'ivy-resume)
(keymap-global-set "<f6>" #'ivy-resume)
(keymap-global-set "M-x" #'counsel-M-x)
(keymap-global-set "C-x C-f" #'counsel-find-file)
(keymap-global-set "<f1> f" #'counsel-describe-function)
(keymap-global-set "<f1> v" #'counsel-describe-variable)
(keymap-global-set "<f1> o" #'counsel-describe-symbol)
(keymap-global-set "<f1> l" #'counsel-find-library)
(keymap-global-set "<f2> i" #'counsel-info-lookup-symbol)
(keymap-global-set "<f2> u" #'counsel-unicode-char)
(keymap-global-set "C-c g" #'counsel-git)
(keymap-global-set "C-c j" #'counsel-git-grep)
(keymap-global-set "C-c k" #'counsel-ag)
(keymap-global-set "C-x l" #'counsel-locate)
(keymap-global-set "C-S-o" #'counsel-rhythmbox)
(keymap-set minibuffer-local-map "C-r" #'counsel-minibuffer-history)
Note: parts of this config can be replaced by using counsel-mode
.
Counsel
ivy-mode
ensures that any Emacs command invoking completing-read
or completion-in-region
will use Ivy for completion.
Counsel takes this further, providing versions of common Emacs
commands that are customized to make the best use of Ivy. For
example, counsel-find-file
has some additional keybindings.
Pressing DEL will move you to the parent directory.
Enabling counsel-mode
remaps built-in Emacs functions that have
Counsel replacements:
Emacs command | Counsel counterpart |
---|---|
execute-extended-command | counsel-M-x |
describe-bindings | counsel-descbinds |
describe-function | counsel-describe-function |
describe-variable | counsel-describe-variable |
describe-symbol | counsel-describe-symbol |
apropos-command | counsel-apropos |
describe-face | counsel-describe-face |
list-faces-display | counsel-faces |
find-file | counsel-find-file |
find-library | counsel-find-library |
imenu | counsel-imenu |
load-library | counsel-load-library |
load-theme | counsel-load-theme |
yank-pop | counsel-yank-pop |
info-lookup-symbol | counsel-info-lookup-symbol |
pop-to-mark-command | counsel-mark-ring |
bookmark-jump | counsel-bookmark |
Installation
Install the counsel
package from GNU ELPA or MELPA.
Swiper
Swiper is an alternative to Isearch that uses Ivy to show an overview of all matches.
A Helm version of Swiper is also available:
swiper-helm
.
Installation
Install the swiper
package from GNU ELPA or MELPA.
Screenshots
There's also a ~ten minute video demo.
Frequently asked questions
-
Q: How do I enter an input that matches one of the candidates instead of this candidate? Example: create a file
bar
when a filebarricade
exists in the current directory. -
A: Press C-M-j. Alternatively, you can make the prompt line selectable with:
(setopt ivy-use-selectable-prompt t)
Contributing
Please see the guidelines for reporting issues and opening pull requests.
Top Related Projects
:cherry_blossom: A command-line fuzzy finder
Find, Filter, Preview, Pick. All lua, all the time.
Fuzzy Finder in rust!
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
A simple, fast and user-friendly alternative to 'find'
An interactive cheatsheet tool for the command-line
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot