Skip to content

Instantly share code, notes, and snippets.

@mrbalihai
Created February 8, 2016 15:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbalihai/66833535d78be19b659d to your computer and use it in GitHub Desktop.
Save mrbalihai/66833535d78be19b659d to your computer and use it in GitHub Desktop.
" Strip the newline from the end of a string
function! Chomp(str)
return substitute(a:str, '\n$', '', '')
endfunction
" Find a file and pass it to cmd
function! DmenuOpen(cmd)
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
endif
execute a:cmd . " " . fname
endfunction
map <c-f><c-f> :call DmenuOpen("e")<cr>
map <c-f><c-v> :call DmenuOpen("vsplit")<cr>
map <c-f><c-h> :call DmenuOpen("split")<cr>
@elhenro
Copy link

elhenro commented Jun 18, 2019

This works great!
in my case i remapped the keys like this:

nmap <leader>r :call DmenuOpen("e")<cr>
nmap <leader>rv :call DmenuOpen("vsplit")<cr>
nmap <leader>rs :call DmenuOpen("split")<cr>

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