[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[OT] Vim Question

Tim Pease

8/20/2006 10:35:00 PM

This is for all the Rubyists out there who can really rock the Vim.
How do you invoke a shell command and pass arguments to said command?

function Put(computer)
!rsync -v -rulptzCF string(getcwd()) . "/" string(a:computer) . ":"
string(getcwd()) . "/"
endfunction

The idea here is that I want a Put function that takes a computer name
as an argument. This function will use rsync to copy all modified
files from the current working directory to the same directory on the
remote computer.

The reason for this is that I'm developing on Windows :( but my code
needs to run on Linux and Solaris. Pushing code to the machines where
autotest will run it is the desired outcome. I don't want to have to
drop out of vim and into a shell prompt each time I do this.

The function I gave above is total crap, but hopefully it conveys the
idea I want to accomplish. Any help or thoughts? A simple example,
maybe?

TwP

6 Answers

Ara.T.Howard

8/20/2006 10:50:00 PM

0

Luke A. Kanies

8/21/2006 12:03:00 AM

0

On Aug 20, 2006, at 5:50 PM, ara.t.howard@noaa.gov wrote:
> here i type
>
> :r !echo arg1 arg2
>
> which says
>
> read in the output of 'echo arg1 arg2'

You can also just type !! with no colon to do the same thing (two
less characters!).

--
Luke Kanies
http://m... | http://reducti... | 615-594-8199



Andy Stewart

8/21/2006 9:51:00 AM

0

Tim,

> This is for all the Rubyists out there who can really rock the Vim.

Well, one tries.

> The idea here is that I want a Put function that takes a computer name
> as an argument. This function will use rsync to copy all modified
> files from the current working directory to the same directory on the
> remote computer.
>
> The reason for this is that I'm developing on Windows :( but my code
> needs to run on Linux and Solaris. Pushing code to the machines where
> autotest will run it is the desired outcome. I don't want to have to
> drop out of vim and into a shell prompt each time I do this.

Why not just edit the files on the machines where autotest runs?

Vim has a mechanism for editing remote files via ftp, rcp, scp, http
and others. I've used it before and it saved a lot of fiddling
around with scripts outside vim. Here's some more information:
http://www.vim.org/tips/tip.php?...

Good luck,
Andy

Tim Pease

8/21/2006 2:28:00 PM

0

On 8/21/06, Andy Stewart <ruth_andy@fastmail.fm> wrote:
>
> Why not just edit the files on the machines where autotest runs?
>
> Vim has a mechanism for editing remote files via ftp, rcp, scp, http
> and others. I've used it before and it saved a lot of fiddling
> around with scripts outside vim. Here's some more information:
> http://www.vim.org/tips/tip.php?...
>
> Good luck,
> Andy

That's a cool little fact to know, but it won't work for me :(

The version controlled copies live on my laptop, but the code needs to
run on a few other machines. Also, when I'm not connected to a
network, it would be hard to edit the files. Thanks for the tip though
:)

TwP

Logan Capaldo

8/21/2006 2:48:00 PM

0


On Aug 21, 2006, at 10:27 AM, Tim Pease wrote:

> On 8/21/06, Andy Stewart <ruth_andy@fastmail.fm> wrote:
>>
>> Why not just edit the files on the machines where autotest runs?
>>
>> Vim has a mechanism for editing remote files via ftp, rcp, scp, http
>> and others. I've used it before and it saved a lot of fiddling
>> around with scripts outside vim. Here's some more information:
>> http://www.vim.org/tips/tip.php?...
>>
>> Good luck,
>> Andy
>
> That's a cool little fact to know, but it won't work for me :(
>
> The version controlled copies live on my laptop, but the code needs to
> run on a few other machines. Also, when I'm not connected to a
> network, it would be hard to edit the files. Thanks for the tip though
> :)
>
Sounds like a job for DSCM such as darcs, git or mercurial. ;)

> TwP
>


Tim Pease

8/21/2006 3:22:00 PM

0

On 8/20/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
> here i type
>
> :r !echo arg1 arg2
>
> which says
>
> read in the output of 'echo arg1 arg2'
>
> yielding
>
> arg1 arg2
>
> into my file. if you don't want output you can do things like
>

Okay, the solution I came up with is to build up the command inside
one of the paste registers (@) and then execute that register. Here
is a simple example that will move to the current working directory
and do a file listing.

function FuncGetls( )
let @g="!cd " . getcwd() . "; ls"
@g
endfunction
command Getls call FuncGetls( )

My full solution for doing the rsync is this ...

command -nargs=1 Put call <SID>Put("<args>")
function <SID>Put(puter)
let s:dir=escape(getcwd(), "\"") . "/"
let @r="!rsync -v -rulptzCF " . s:dir . " " . a:puter . ":" . s:dir
@r
endfunction

Now I can send all the files I've modified to another computer by
typing the following command ...

:Put panic

where panic is the name of the machine.

TwP