Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Created February 18, 2022 21:33
Show Gist options
  • Save thingsiplay/354fe98d27cb6625bf90de3b60c7a2ec to your computer and use it in GitHub Desktop.
Save thingsiplay/354fe98d27cb6625bf90de3b60c7a2ec to your computer and use it in GitHub Desktop.
vimh - Open Vim in help page directly from terminal (fzf edition)
#!/bin/env bash
# vimh - Open Vim in help page directly from terminal (fzf edition)
#
# Usage:
# If no argument is given, then a fuzzy finder search is initiated.
#
# vimh [tag]
# vimh ''
# vimh '<c-p>'
#
# Note: The "vim_help_tags" path could be different on your system. This
# script also requires the program "fzf". An empty argument will show up main
# help entry.
# Modified script based on:
# Special thanks to Reddit user "duppy-ta".
# https://www.reddit.com/r/vim/comments/rdgjs9/simple_commandscript_to_open_vim_in_help_page/ho2tvyv/
vim_help_tags=/usr/share/vim/vim82/doc/tags
if [[ "$#" == 0 ]]
then
[[ ! -f $vim_help_tags ]] && exit 1
tag=$(fzf --cycle --sync --nth=1 --with-nth=1 < $vim_help_tags | cut -f1)
if [[ ! "$tag" == "" ]]
then
vim -c ":help $tag | only"
fi
else
vim -c ":help $1 | only"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment