Browse Source

Ajout de mappings pour ouvrir des fichiers avec dmenu

Thibaut Marty 9 years ago
parent
commit
7528911190
2 changed files with 22 additions and 0 deletions
  1. 21 0
      dmenu.vim
  2. 1 0
      vimrc

+ 21 - 0
dmenu.vim

@@ -0,0 +1,21 @@
+"# Ouvrir rapidement un fichier avec dmenu
+" De : http://leafo.net/posts/using_dmenu_to_open_quickly.html
+
+" 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 | dmenu -i -l 20 -p " . a:cmd))
+  let fname = Chomp(system("find . | dmenu -i -l 20 -p :" . a:cmd))
+  if empty(fname)
+    return
+  endif
+  execute a:cmd . " " . fname
+endfunction
+
+" Mappings
+nmap <Leader>e :call DmenuOpen("e")<CR>
+nmap <Leader>E :call DmenuOpen("tabe")<CR>

+ 1 - 0
vimrc

@@ -2,6 +2,7 @@ source ~/.vim/set.vim
 source ~/.vim/fonctions.vim
 source ~/.vim/plugins.vim
 source ~/.vim/statusline.vim
+source ~/.vim/dmenu.vim
 source ~/.vim/theme.vim
 source ~/.vim/specifiques.vim
 source ~/.vim/mappings.vim