Created
November 15, 2025 20:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| } |
Author
lmmx
commented
Nov 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment