Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1679583
  • 博文数量: 410
  • 博客积分: 9563
  • 博客等级: 中将
  • 技术积分: 4517
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-03 19:59
个人简介

文章分类

全部博文(410)

文章存档

2017年(6)

2016年(1)

2015年(3)

2014年(4)

2013年(32)

2012年(45)

2011年(179)

2010年(140)

分类: LINUX

2011-02-22 22:22:30

最近需要经常登录服务器编辑远程文件
方法一:
ssh -X user@remote 
然后用gvim编辑,但是有个缺点是服务器上的vim插件没有,各种配置都是默认的
方法二:()
sudo apt-get install sshfs

and then

sshfs remoteuser@remotehost:/remote/path /local/mountpoint

And that will let you edit your remote files as if the where on your local file system.

To make it even smoother you can add a line to /etc/fstab

sshfs#remoteusername@remotehost:/remote/path /local/mountpoint fuse user,noauto

方法三:应用netrw.vim插件

It would be useful to note if netrw.vim was loaded by vim when it started.

:echo exists("g:loaded_netrwPlugin")

For opening files over ssh, you need your local machine's public key in the server's authorized keys. Following help section in vim documentation explains it pretty well.

:help netrw-ssh-hack

Quick way to export public key would be by using ssh-copy-id (if available).

(记得用密钥,不然每一步都要密码烦死了)
ssh-copy-id user@host

And have a look at netrw documentation for network file editing over other protocols.

:help netrw

配合project插件使用,scp的文件路径很长,可以在project插件中建立一个项目
在~/.vimprojects中添加
  1. DB{
  2. scp://user@server/path/filename
  3. }
阅读(2923) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~