Skip to content

Instantly share code, notes, and snippets.

@HersonHN
Last active February 8, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HersonHN/5414492 to your computer and use it in GitHub Desktop.
Save HersonHN/5414492 to your computer and use it in GitHub Desktop.
Global Search in VIM
function! GlobalSearch()
let text = escape(input("what do you want to search?: "), '\\/')
if text == ""
echo "" | return
endif
let extension = escape(input("Wich extension? (* for all): "), '\\/')
if extension == ""
echo "" | return
endif
let search_command = ':lvim /\V' . text . '/gj ./**/*.' . extension
try
execute search_command
catch
echo "Nothing found"
return
endtry
lwindow
endfunction
""" mapping the function to leader-shift-f
noremap <leader>F :call GlobalSearch() <CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment