Way of opening local gVim edit remote file via putty?

987 views
Skip to first unread message

Laph

unread,
Jul 3, 2011, 4:31:51 AM7/3/11
to vim...@googlegroups.com

Hi all,

I used to coding in remote unix server by connecting via putty in my windows desktop, but the problem is that the account of unix server is shared for varies users who are using vim, too. This causes the remote vimrc chaos.

So I think it would be a great idea using local gvim with my own vimrc to edit remote files. I know the way of `:e scp://...' to edit the specified remote file via scp, but it need to switch from putty to gvim when I want to open remote files after some operation in the terminal, say grep, tail, or make. And switch it back if I want to take another operation. It is quite inefficient.

Is it possible a way in putty terminal opening my local gvim in windows desktop to edit the remote file without manually switching window and retyping `:e scp://...' again and again?

Thanks in advance!

Gary Johnson

unread,
Jul 3, 2011, 12:04:58 PM7/3/11
to vim...@googlegroups.com

I can't think of a way to do what you want, but an alternative
solution would be to use your own vimrc on the remote server.
Create your own vimrc and give it a unique name such as
~/.vimrc.your_name. Then at the start of each PuTTY session,
execute

alias vim='vim -u ~/.vimrc.your_name'

See

:help -u

Regards,
Gary

hsitz

unread,
Jul 3, 2011, 9:20:16 PM7/3/11
to vim_use
On Jul 3, 1:31 am, Laph <laph...@gmail.com> wrote:
> Hi all,
>
>
> So I think it would be a great idea using local gvim with my own vimrc to
> edit remote files. I know the way of `:e scp://...' to edit the specified
> remote file via scp, but it need to switch from putty to gvim when I want to
> open remote files after some operation in the terminal, say grep, tail, or
> make. And switch it back if I want to take another operation. It is
> quite inefficient.
>

From the Vim help for 'scp':
-----------------------------------------
"Netrw supports "transparent" editing of files on other machines using
urls
(see |netrw-transparent|). As an example of this, let's assume you
have an
account on some other machine; if you can use scp, try: >

vim scp://hostname/path/to/file
"
--------------------------------------------

I think there are some questions/answers on StackOverflow regarding
this. Try searching there for '[vim] remote file edit':
http://stackoverflow.com/search?q=[vim]+remote+file+edit

-- Herb

Charles Campbell

unread,
Jul 5, 2011, 11:41:44 AM7/5/11
to vim...@googlegroups.com
Does gvim work for you on your local system?

I'm not sure what you mean by "it need to switch from putty to gvim". I
would've thought that gvim would be running in its own window and putty
in its own separate window, so switching between them is an o/s mousy
thing. You should be able to simply leave the gvim window up and
running, and so not need to type ":e scp://..." repeatedly.

Or perhaps you should try

:e scp://somehost/

(note the trailing slash) and "edit" the remote directory. Pick a
file, edit it, perhaps :w it; use :Rex to return to the netrw
directory listing, etc.

Regards,
Chip Campbell

pansz

unread,
Jul 5, 2011, 8:29:43 PM7/5/11
to vim...@googlegroups.com
On Sun, Jul 3, 2011 at 4:31 PM, Laph <lap...@gmail.com> wrote:
> Is it possible a way in putty terminal opening my local gvim in windows
> desktop to edit the remote file without manually switching window and
> retyping `:e scp://...' again and again?
> Thanks in advance!

Theoretically, it is possible, you can write some daemon app which
listens in your local computer, and a client utility which run in your
remote server.

When you execute a command in your remote server, it communicates with
the daemon app in your local computer, and the local app calls gvim
--remote-silent to do what you want, and then switch the focus into
your local gvim.

You need to write a simple client/server socket app to do this, which
could be less than 100 lines.


But IMO the better way is to define your own .vimrc in the remote
computer and launch vim with "vim -u .vimrc.yours", you can redefine
the 'rtp' in .vimrc so that the .vim directory can be your own
directory. you can create an alias for that.

Charles Campbell

unread,
Jul 12, 2011, 10:27:27 AM7/12/11
to vim...@googlegroups.com
Also, one may use the url notation from the command line:

vim scp://hostname/path/file

and so perhaps you could just re-issue that editing command using
whatever command line history is available. At least you wouldn't have
to re-type it.

Regards,
Chip Campbell

Fan Hongtao

unread,
Jul 18, 2011, 1:06:31 AM7/18/11
to vim...@googlegroups.com

I do it this way:
First, add a alias in ~/.bashrc
     aliase  fht='source ~/fht/.bashrc'

Second, make your own dir
    cd
    mkdir   fht

Third, create your own .bashrc in that dir, here is some snippet
     # export 'HOME' for convenience
     export   MY_HOME=~/fht
     # settings for vim
      export   MYVIMRC='$MY_HOME/.vimrc
      export   VIMINIT='source  $MYVIMRC'

Fourh, create a .vimrc in your dir

When login, execute the aliase, and you can your own config for vim. Just as if the account is used only by yourself.

Fan Hongtao

> --
> 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
Reply all
Reply to author
Forward
0 new messages