On Tue, Jan 13, 2009 at 17:22, Per Thulin
<per.thu...@valentinewebsystems.se> wrote:

> One simple little integration thing that would fix it all would be if could
> do this:
>
> 1. From vim, run :shell
> 2. Find the files I'm after
> 3. Open these in the vim session I ran :shell from.
>
> Hold your hats now, but Emacs users can do this. From Emacs they do the
> equivalent of running :shell, then navigate to another directory which
> becomes Emacs working directory. Now they can do the equivalent of :e <some
> file in that directory>.
>
> Thanks!
> -Per Thulin

This sound incredibly useful. This idea has never occurred to me, but it is
really good, and I will use it. Below you will find my take on how to achieve
this. There is probably much room for improvement.

(Important note: You mentioned you also use OS X. Well, sorry. I don't know
 whether this will work. It does on Linux.)

1.

Create a bash file called "choose" (say, in your ~/bin), and enter the
following:

#!/bin/bash

for filename in $*
do
    echo `readlink -f $filename` >> /tmp/vim_choose_files
done

2.

Add the folowing to your .vimrc:

function s:ShellChoose ()
    call system("rm -f /tmp/vim_choose_files")
    shell
    let l:files=system("cat /tmp/vim_choose_files")
    if !v:shell_error
        let l:files=substitute(l:files, "\n", " ", "g")
        exec "argadd ".files
    endif
endfunction

command -nargs=0 Shell call s:ShellChoose()

3.

Use.

Usage instructions:

a. Use ":Shell" instead of ":shell".
b. Go to any directory, and choose files you would like to edit using the
   "choose" bash script.

   Examples:

       choose a.txt
       choose *.txt

   You don't have to choose all files at once.
c. When you <C-d> your way back to vim, the files you've chosen will be added to
   the argument list.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to