Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ By default, `fuzzysearch` doesn't match over spaces. That means that `"fr"` will
If you dislike this behaviour, set `g:fuzzysearch_match_spaces = 1`.
The reasoning behind the default behaviour is that it is much easier to narrow down searches, in order to re-use patterns later, for example in a replacement by `:%s//<new_string>/g`.

== Sensitivity
Determine how many wildcard chars between input chars should be a match.
0 = off, input `"fr"` will match `"f.*r"`, 2 will match `"f._._.r"`, 1 `"f._.r"` and so on.
Ex: `g:fuzzysearch_sensitivity = 3` (default is 0)


=== Useful mappings
Replace in file using last search: `nnoremap <leader>r :%s///g<left><left>` +
Expand All @@ -25,4 +30,5 @@ I find it very useful to create a fuzzy search quickly, then replace all instanc
`g:fuzzysearch_ignorecase = 1` +
`g:fuzzysearch_max_history = 30` +
`g:fuzzysearch_match_spaces = 0`
`g:fuzzysearch_sensitivity = 0`

9 changes: 7 additions & 2 deletions plugin/fuzzysearch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let g:fuzzysearch_hlsearch=1
let g:fuzzysearch_ignorecase=1
let g:fuzzysearch_max_history = 30
let g:fuzzysearch_match_spaces = 0
let g:fuzzysearch_sensitivity = 0

function! s:getSearchHistory()
return filter(map(range(1, 20), 'histget("/", v:val-20)'), '!empty(v:val)')
Expand All @@ -29,11 +30,15 @@ function! s:restoreHistory(histList)
let @/=oldSearch
endfunction

let s:fuzzySensitivity = '-'
if g:fuzzysearch_sensitivity
let s:fuzzySensitivity = ','.g:fuzzysearch_sensitivity
endif

if g:fuzzysearch_match_spaces
let s:fuzzyChars = '.\\{-}'
let s:fuzzyChars = '.\\{'.s:fuzzySensitivity.'}'
else
let s:fuzzyChars = '\[^\\ ]\\{-}'
let s:fuzzyChars = '\[^\\ ]\\{'.s:fuzzySensitivity.'}'
endif

function! s:update(startPos, part)
Expand Down