Skip to content

Instantly share code, notes, and snippets.

@chalmagean
Last active August 29, 2015 14:23
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 chalmagean/478b0f48e73eb35371e4 to your computer and use it in GitHub Desktop.
Save chalmagean/478b0f48e73eb35371e4 to your computer and use it in GitHub Desktop.
" Find where a partial is called
" With no arguments it uses the current file name to do the search.
" You can also pass a string to search for and it will do a search for
" a line matching render.*<your_string>
function! GrepPartial(...)
if a:0
let pattern = "render.*" . a:0
else
let filename = substitute(expand("%:t:r:r"), "^_", "", "")
let pattern = "render.*" . filename
endif
execute "grep! -Re '" . pattern . "' app/views/"
endfunction
command! -nargs=? GrepPartial call GrepPartial(<args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment