I'm trying to use Sublime Text 2 as an editor when I SSH in to my work server, and I'm stumped. I found this http://urbangiraffe.com/2011/08/13/remote-editing-with-sublime-text-2/ (among many other posts) that looks like it might help, but I don't follow it exactly, particularly with what values I should put in for the remote variable in line 5. I set "/Users/path/to/local/copy" to my local root directory, but I don't know if that's right or if there's more to do. Any thoughts? I'm on OSX10.8


当前回答

你可以试试我一直在研究的一种叫做“xeno”的东西。它将允许您通过SSH连接打开Sublime文本(或任何本地编辑器)中的文件/文件夹,并自动将更改同步到远程机器。它应该可以在几乎所有的POSIX系统上工作(我自己使用它从OS X连接到Linux机器并在Sublime Text中编辑文件)。它是免费的,开源的。我想要一些反馈。

For more information: it's basically a Git/SSH mashup written in Python that allows you to edit files and folders on a remote machine in a local editor. You don't have to configure kernel modules, you don't need to have a persistent connection, it's all automatic, and it won't interfere with existing source control because it uses an out-of-worktree Git repository. Also, because it's built on Git, it's extremely fast and supports automatic merging of files that might be changing on both ends, unlike SSHFS/SFTP which will just clobber any files with older timestamps.

其他回答

作为@ubik回答的后续,以下是让“subl”命令在远程服务器上工作的三个简单(一次性)步骤:

使用Sublime包管理器在Sublime Text中安装rsub包 [Local]执行以下Bash命令(这将建立一个SSH隧道,这是rsub的秘密武器): printf "Host *\n RemoteForward 52698 127.0.0.1:52698" >> ~/.ssh/config 在远程服务器上执行以下Bash命令(这将安装subl shell命令): sudo wget -O /usr/local/bin/subl https://raw.github.com/aurora/rmate/master/rmate Sudo chmod +x /usr/local/bin/subl

瞧!你现在在SSH上使用Sublime Text。

你可以从服务器上用subl ~/test.txt打开Sublime Text中的示例文件

我在Windows上使用了4种方法:SFTP, WinSCP, Unison和Sublime Text在Linux上使用X11通过SSH转发到Windows(是的,你可以这样做而不需要混乱的配置和使用免费工具)。

如果你能在你的Linux机器上安装软件,第四种方法是最好的。

第四种方法:

MobaXterm

Install MobaXterm on Windows SSH to your Linux box from MobaXterm On your linux box, install Sublime Text 3. Here's how to on Ubuntu At the command prompt, start sublime with subl That's it! You now have sublime text running on Linux, but with its window running on your Windows desktop. This is possible because MobaXterm handles the X11 forwarding over SSH for you so you don't have to do anything funky to get it going. There might be a teeny amount of a delay, but your files will never be out of sync, because you're editing them right on the Linux machine.

注意: 当调用subl时,如果它抱怨某个库-确保你安装它们成功地从mobaxterm调用sublimetext。

如果你不能在你的Linux机器上安装软件,最好是Unison。为什么?

它是免费的 它的速度非常快 它是可靠的,并且不关心您使用哪个编辑器 您可以创建自定义忽略列表

SFTP

设置: 安装SFTP Sublime Text包。此软件包需要license支持。

创建一个新文件夹 打开它作为一个崇高的文本项目。 在侧边栏中,右键单击文件夹并选择Map Remote。 编辑sftp-config文件。json文件 右键单击步骤1中的文件夹,选择下载。 在本地工作。

在sftp-config中,我通常设置:

"upload_on_save": true,
"sync_down_on_open": true,

除了机器的SSH终端外,这给了我一个相当无缝的远程编辑体验。

温森

Install and run WinSCP Go to Preferences (Ctrl+Alt+P) and click on Transfer, then on Add. Name the preset. Set the transfer mode to binary (you don't want line conversions) Set file modification to "No change" Click the Edit button next to File Mask and setup your include and exclude files and folders (useful for when you have a .git/.svn folder present or you want to exclude build products from being synchronized). Click OK Connect to your remote server and navigate to the folder of interest Choose an empty folder on your local machine. Select your newly created Transfer settings preset. Finally, hit Ctrl+U (Commands > Keep remote directory up to date) and make sure "Synchronize on start" and "Update subdirectories" are checked.

从那时起,WinSCP将使您的更改保持同步。

使用SublimeText在本地文件夹中工作。只要确保Sublime Text设置为从正在编辑的文件中猜测行尾即可。

一致

I have found that if source tree is massive (around a few hundred MB with a deep hierarchy), then the WinSCP method described above might be a bit slow. You can get much better performance using Unison. The down side is that Unison is not automatic (you need to trigger it with a keypress) and requires a server component to be running on your linux machine. The up side is that the transfers are incredibly fast, it is very reliable and ignoring files, folders and extensions are incredibly easy to setup.

Lsyncd似乎是SSHFS方法的一个不错的替代方案。如果你使用“-delay 0”,它可以实时工作。

I am on MacOS, and the most convenient way for me is to using CyberDuck, which is free (also available for Windows). You can connect to your remote SSH file system and edit your file using your local editor. What CyberDuck does is download the file to a temporary place on your local OS and open it with your editor. Once you save the file, CyberDuck automatically upload it to your remote system. It seems transparent as if you are editing your remote file using your local editor. The developers of Cyberduck also make MountainDuck for mounting remote files systems.

您可以使用rsub,它的灵感来自TextMate的rate。从描述来看:

Rsub是Sublime Text 2的TextMate 2的“rate”特性的实现,允许使用SSH端口转发/隧道在远程服务器上编辑文件。

这里有一个关于如何正确设置它的好教程:(断开链接)http://log.liminastudio.com/writing/tutorials/sublime-tunnel-of-love-how-to-edit-remote-files-with-sublime-text-via-an-ssh-tunnel