Skip to content

Instantly share code, notes, and snippets.

@lmmx
Created November 15, 2025 20:59
Show Gist options
  • Select an option

  • Save lmmx/6112346d7c2fc2ca83a0a07ab9efdbe8 to your computer and use it in GitHub Desktop.

Select an option

Save lmmx/6112346d7c2fc2ca83a0a07ab9efdbe8 to your computer and use it in GitHub Desktop.
Open a file in vim (the first match for the name using fd) and immediately execute a search
function vsearch ()
{
local filename="$1";
local search_string="$2";
if [ -z "$filename" ] || [ -z "$search_string" ]; then
echo "Usage: vsearch filename 'search_string'";
return 1;
fi;
vim $(fd -1 "$filename") -c "/$search_string" -c "normal! zz"
}
@lmmx
Copy link
Author

lmmx commented Nov 15, 2025

Screenshot from 2025-11-15 20-58-00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment