dmenu.vim 604 B

123456789101112131415161718192021
  1. "# Ouvrir rapidement un fichier avec dmenu
  2. " De : http://leafo.net/posts/using_dmenu_to_open_quickly.html
  3. " Strip the newline from the end of a string
  4. function! Chomp(str)
  5. return substitute(a:str, '\n$', '', '')
  6. endfunction
  7. " Find a file and pass it to cmd
  8. function! DmenuOpen(cmd)
  9. "let fname = Chomp(system("git lsœ-files | dmenu -i -l 20 -p " . a:cmd))
  10. let fname = Chomp(system("find . | dmenu -i -l 20 -p :" . a:cmd))
  11. if empty(fname)
  12. return
  13. endif
  14. execute a:cmd . " " . fname
  15. endfunction
  16. " Mappings
  17. nmap <Leader>e :call DmenuOpen("e")<CR>
  18. nmap <Leader>E :call DmenuOpen("tabe")<CR>