Saturday, October 1, 2016

Re: Possible to have :e autocompletion show entries from multiple folders?

On Sat, Oct 01, 2016 at 11:58:54AM -0700, Eric Pruitt wrote:
> Is there some way to make command mode filename autocompletion show
> folders from multiple directories? I would like :e autocompletion to
> show files from Vim's $PWD at launch and files from paths relative to
> the current buffer. In my Vim configuration, I already have "autocmd
> BufEnter * silent! lcd %:p:h", so I just need to figure out how to also
> show files from $PWD from using :e autocompletion.

Since this feature is reminiscent of Bash's CDPATH handling, I searched
for "vim cdpath" and found https://gist.github.com/jferris/7122963 . I
began to modify this code to support file paths with :e, but after some
more searching and consideration, I decided to use a cabbrev mapping
instead. This is what I came up with:

cabbrev E e <C-r>=$PWD<CR>/<C-r>=getchar(0) == 32 ? '' : getchar(0) == 32<CR>

This will make :E+<Space> prefill :e with the value of $PWD which should
be the folder Vim was launched in.

Eric

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: