Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Effective use of gvim over a network

Tags:

vim

windows

ftp

I currently use vim in a telnet window for editing code (very old school!). There is a lot of source code (mainly C), so I use tags, cscope etc. to get around. This is ok as far as it goes, but network latency can make every keystroke "laggy", which is not so good!

I'd like to use gvim on my Windows PC (or any editor that can be set up to do this) to:

  1. Edit files remotely via FTP (gvim already can do this)
  2. Use a TAGS file that is either stored locally or on the server (probably more efficient to use one on the server, then I don't have to FTP every file down). I suppose generating the file then FTPing to the proper location on my local machine would be ok.
  3. Run shell commands as if I were in the directory of the file on the server (make, various scripts etc.). I do have ssh access to the machine so I can't think that this would be a problem.

I'm a little familiar with vimscript, so I don't mind doing a little glueing. I thought that I can't be the only person who has ever wanted to do this - hence asking here.

Like I said - if there is any decent editor that has this "built-in", then I don't mind switching!

like image 576
Greg Reynolds Avatar asked Mar 05 '09 09:03

Greg Reynolds


3 Answers

You can also use SSH to edit your file remotely with vim.

:e scp://remote.host.com/project/file

And then use SSH to call make remotely:

:!ssh remote.host.com '(cd project; make)'

ctags

In order to use ctags remotely, I would create the tags file remotely and copy it to the local machine and add scp://remote.host.com/project/ to each file name in the tags files. You can do this with something like

:%s#^\(\w\+\)\t#\1\tscp://remote.host.com/project/#

on the tags file. Then when working on a remote file you use ':set tags=local_ctags/tags' to reference the local (modified) version of the tags file.

like image 115
f3lix Avatar answered Oct 06 '22 21:10

f3lix


'tags' option tells Vim where to look for TAGS file, though I'm not sure whether Vim allows ftp:// or scp:// paths in this option.

You can run commands on server using :!ssh ...

But don't you think it would be better to use one of the source control systems, work with files locally and then put updated files on server?

like image 24
Paul Avatar answered Oct 06 '22 22:10

Paul


How about mounting remote directory localy? You can export it as an SMB share, NFS mount, or there are several equivalents of SSH filesystem (sshfs) available for Windows.

like image 36
kyku Avatar answered Oct 06 '22 21:10

kyku