oysandvik94 / dotfiles

1 stars 0 forks source link

Wildcard #40

Closed oysandvik94 closed 5 months ago

oysandvik94 commented 5 months ago

Enhance search for navigation

With this small tweak for command line you can get arguably a bit more precise way to navigate using vim's search:

# enhance search with <space> as "whatever"
# to enter literal <space> use <C-v><space>
cnoremap <expr> <space> getcmdtype() =~ '[/?]' ? '.\{-}' : "<space>"

Basically, it treats every space as a non-gready wildcard: https://asciinema.org/a/4bNrmPZd2KjkchxnykpWwUFj0

It mimics what Emacs has with a dedicated setting and I found it quite useful in vim as well. CTRL-W deletes .\{-} if needed.