Friday, June 3, 2011

Re: reading contents from a file under directories specified by "path" variable

* Aman Jain [2011.06.03 14:40]:
> But is there a way for reading in the contents of files present under
> directories,
> specified by path variable e.g.
> :r file_inside_dir<TAB>

As you noticed, :read doesn't consult 'path'.

Here's a quick implementation:

fun! Read(file)
let full_path = findfile(a:file)
exe "read " . full_path
endfun

fun! PathComplete(A,L,P)
return split( globpath(&path, a:A."*"), "\n")
endfun

command! -complete=customlist,PathComplete -nargs=1 Read call Read('<args>')

Use like so:

:Read foo<tab>

HTH,

--
JR

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: