From 3dbe13fd86884408687504303e782d844fe277cb Mon Sep 17 00:00:00 2001 From: Joel Palmer Date: Fri, 30 Apr 2021 16:38:50 -0500 Subject: [PATCH] search locally for vim help --- public dots/zsh/functions.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public dots/zsh/functions.zsh b/public dots/zsh/functions.zsh index 238edce..f56a57c 100644 --- a/public dots/zsh/functions.zsh +++ b/public dots/zsh/functions.zsh @@ -119,12 +119,26 @@ cdg() { file=$(fd -H -g .git | fzf) && dir=$(dirname "$file") && cd "$dir" } +fvh() { + rg "$1" --ignore-case --files-with-matches --no-messages ~/notes/ ~/dotfiles/ ~/.vim/ ~/.config/nvim/ | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 6 '$1' || rg --ignore-case --pretty --context 6 '$1' {}" --preview-window=right:60% --multi --select-1 --exit-0 +} + # for `vg` grep- find-in-file(s) fif() { if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi rg --ignore-case --files-with-matches --no-messages "$1" | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 6 '$1' || rg --ignore-case --pretty --context 6 '$1' {}" --preview-window=right:60% --multi --select-1 --exit-0 } +# search for local Vim help using fvh +vh() { + local file + file=$(fvh $1) + if [[ -n $file ]] + then + nvim $file -c /$1 -c 'norm! n zz' + fi +} + # find in files - open in Vim - go to 1st search result # vim - grep - takes a query to grep vg() {