summary refs log tree commit diff stats
path: root/doc/examples/vim_file_chooser.vim
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-03-09 18:48:02 +0100
committerhut <hut@lavabit.com>2013-03-09 18:48:02 +0100
commitd2c7d024290ee95afa418975c728ad64172dcfec (patch)
treeeea0659eab7bb0c7b9cc2026468c840d7f22a5c9 /doc/examples/vim_file_chooser.vim
parent62af277734f05f27f20467393c9d997012ddd2b4 (diff)
downloadranger-d2c7d024290ee95afa418975c728ad64172dcfec.tar.gz
move examples to doc/examples
Diffstat (limited to 'doc/examples/vim_file_chooser.vim')
-rw-r--r--doc/examples/vim_file_chooser.vim17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/examples/vim_file_chooser.vim b/doc/examples/vim_file_chooser.vim
new file mode 100644
index 00000000..4f5fa3f2
--- /dev/null
+++ b/doc/examples/vim_file_chooser.vim
@@ -0,0 +1,17 @@
+" Compatible with ranger 1.4.2 through 1.6.*
+"
+" 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>