swiper
Fuzzy search lines in current window.
Supports regex, negate, match highting, case sensitive search.
a copy of emacs swiper: the thing I missed most in vscode.
Search "swiper !not Test"
matches a line with SWiPeR Test
without mentions of not
string.
Installation
Install this extension.
Commands
swiper.swiper-word-at-cursor
search the current word at cursor.
swiper.swiper
search the last value tried.
Quick tutorial
Invoke command Swiper: Swiper Search/Resume
and start typing.
basic rules:
- Search either literal string e.g.
abc
or javascript regex /.../
.
- Search strings separated by space are AND-ed together. e.g. "a b" matched lines with "a" and "b" on the same line.
- Search string prefixed with
!
negates the search, "a !b" matches lines with "a" but not "b". Use regex /\!/
if you want to match "!"
literal string.
Search string starts with !
does not contribute to the border highlights.
- Default case insensitive search. Upcased search term matches case sensitively.
Some quick Example:
# search wildcard
/command.*swiper/
a b # matches lines with a and b
a !b # matches lines with a but not b
/lint|display/ # lint OR display
lint|display # searches the literal string "lint|display"
# line starts with test
/^test/
a B # matches "aB", "AB"
/\(.*\)/ # matches paren
!/\(.*\)/ # do not match paren
Configuration
You can configure this extension via command palette
(F1 on my machine) -> Preferences: Open User Settings (JSON)
, add the following snippet to the open configuration file:
...
"swiper.selectMatch": false
}
Configuration points of this extension
swiper.selectMatch
(default true), controls if the picked match is selected. Set to false, cursor jumps to the end of the match word.
Motivation
I come from emacs to VScode, vscode is awesome, but misses a few features i do daily in emacs. This is one of them.
More on my motivation: medium link
I wrote a blog that covers achieving some my other emacs workflows in VScode.
TODO
- [x] somehow test on non-macOS?
- [x] search all file in the workspace.
Use VScode search feature.
- [x] if upper case char typed, turn to case sensitive search for that subSearchString.
Done
- [x] do not save tmp file for unsaved buffer.
misc
publish URL
dev guide
# make whatever change, bump package.json
vsce package
# then release to the vscode marketplace publish page.