summary refs log tree commit diff stats
path: root/examples/vim_file_chooser.vim
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-06 06:32:04 +0200
committerhut <hut@lavabit.com>2012-08-06 06:39:26 +0200
commit796074b541aaca459c594fe517c11d275778eef6 (patch)
tree0cc5c6450625a97a3375d6856b4ef07ca581ecdf /examples/vim_file_chooser.vim
parent13cb3fc49c07ba45f12508000ac615ff2e9b3e23 (diff)
downloadranger-796074b541aaca459c594fe517c11d275778eef6.tar.gz
added the examples from the man page to the examples directory
I guess a whole directory for examples scales better than having them in
the man page.
Diffstat (limited to 'examples/vim_file_chooser.vim')
-rw-r--r--examples/vim_file_chooser.vim15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/vim_file_chooser.vim b/examples/vim_file_chooser.vim
new file mode 100644
index 00000000..a44ab2b7
--- /dev/null
+++ b/examples/vim_file_chooser.vim
@@ -0,0 +1,15 @@
+" Add ranger as a file chooser in vim
+" 
+" If you add this function and the key binding to the .vimrc, ranger can be
+" started using the keybinding ",r".  Once you select a file by pressing
+" enter, ranger will quit again and vim will open the selected file.
+
+fun! RangerChooser()
+    exec "silent !ranger --choosefile=/tmp/chosenfile " . expand("%:p:h")
+    if filereadable('/tmp/chosenfile')
+        exec 'edit ' . system('cat /tmp/chosenfile')
+        call system('rm /tmp/chosenfile')
+    endif
+    redraw!
+endfun
+map ,r :call RangerChooser()<CR>