Vim 的轻松 FTP 发布(如 Coda)
我已经专门使用 Vim (MacVim) 几个月了,我喜欢它。不过,在使用 Vim 之前,我使用的是 Coda(我使用的是 OSX),而我怀念 Coda 的一件事是,每当我编辑文件时,它都会标记我的文件以通过 FTP 发布。然后我可以选择单独上传修改后的文件单个文件,或一次性发布所有文件。
Vim 中有什么可以做到这一点或类似的事情吗?
我知道 netrw 可以直接通过 FTP 进行编辑,但我的所有站点都作为在线站点的镜像在本地运行,因此我需要在本地编辑并在需要时远程发布文件。我用谷歌搜索解决方案但找不到任何东西。
在编辑器中,我在 Vim 中的工作效率要高得多,但是当我单独编辑文件时,必须打开 FTP 程序并在文件之间进行搜索和啄食复制,这是一种真正的痛苦,并且使我的工作效率降低与在 Coda 中工作相比,在网站上工作的整体效率更高。
欢迎任何建议:)
I've been using Vim (MacVim) exclusively for months now, and I love it. Before using Vim though, I used Coda (I'm on OSX), and the one thing I miss about Coda is the way it marks my files for publishing via FTP whenever I edit them. I can then choose to upload the modified files single files individually, or to publish all of them in one go.
Is there anything that will do this or similar in Vim?
I'm aware netrw can edit directly over FTP, but I have all my sites running locally as mirrors of the online sites, so I need to edit locally and publish files remotely as and when I need. I've Googled for solutions but can't find anything.
I'm far more productive in Vim while in the editor, but having to open up an FTP program and hunt and peck to copy across files as I edit them seperately is a real pain, and makes me less productive overall when working on websites when compared to working in Coda.
Any suggestions welcome :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Transmit、Cyberduck 和 YummyFTP(我所知道的)都有自己的“自动文件夹同步”版本,您可以在本地工作,任何修改的文件都会在更改时上传:您设置一个“观察者”,而无需点击再次使用特殊按钮或快捷方式。
如果您只想使用 MacVim,您可以编写一个小命令来在保存时上传当前文件:一个使用当前文件路径构建
scp
命令的脚本。但这对我来说似乎不太便携/实用。看来有些人已经写过类似的东西: 这里 和 那里。正确的方法是(不仅在我看来)至:
将所有内容都放在某种 VCS 下,例如 Git、Subversion 或 Mercurial 或任何能让您满意的东西
在本地克隆/签出中编写代码并在本地服务器上进行测试
仅提交工作代码
将里程碑推送到您和您的客户用来测试所有内容的登台服务器,这部分可以通过提交后挂钩或类似的东西自动化
仅在生产服务器上部署经过验证的更改。
所有上述版本控制系统都可以直接从 Vim 命令行使用
:!git commit
或:!svn update
...如果您需要更多抽象,逃犯(仅限 Git)或 VCSCommand(多 VCS,我的选择)可以提供帮助。关于由于上传文件而导致的生产力损失:我认为这是非常正常的,因为您本质上执行非常不同的任务,并且神经需求非常不同。在浏览器中预览布局更改、在 Photoshop 中查找颜色或任何其他类似任务时,也会遇到这种减速现象。我不知道有什么方法可以在 Vim 中试用 Photoshop、Chrome 的开发工具或 Outlook,而且我认为这样的小玩意不可能真正存在,所以你可能不得不忍受它。
Transmit, Cyberduck and YummyFTP (the ones I know) all have their own version of "automated folder syncing" where you work locally and any modified files are uploaded on change: you setup an "observer" and never have to hit a special button or shortcut again.
If you want to only use MacVim you could write a little command that uploads the current file on save: a script that would use the current file's path to construct an
scp
command. But this doesn't seem very portable/practical to me. It appears some people have already written something like that: here and there.The right way is (not only in my opinion) to:
have everything under some kind of VCS like Git, Subversion or Mercurial or whatever floats your boat
write your code in a local clone/checkout and test the hell out of it on a local server
commit only working code
push milestones to a staging server used by you and your clients to test everything, this part can be automated via a post-commit hook or something like that
deploy only validated changes on your production server.
All the aforementioned Version Control Systems can be used directly from Vim's command line with
:!git commit
or:!svn update
… If you need more abstraction, Fugitive (Git-only) or VCSCommand (multi-VCS, my choice) are here to help.On your loss of productivity due to uploading files: I think it's very normal because you essentially perform very different tasks with very different neurological needs. This speed bump can also be experienced when previewing a layout change in your browser, looking up a color in Photoshop or any other similar task. I don't know of a way to pilot Photoshop, Chrome's dev tools or Outlook from within Vim and I don't think such a gizmo could reallistically exist so you will probably have to bear with it.
你可以尝试 git-ftp - 一个基于 git 的命令行 ftp 客户端。然后,您可以将您的项目作为 Git 存储库进行管理,并且 git-ftp 只会上传标有 Git 的文件 - 并且仅当它们已更改时。
缺点是您必须学习 Git - 这对于您的需求来说有点过分了。
好处是你将学习和使用 Git。
You can try git-ftp - a git based command line ftp client. Then you can manage your project as a Git repository, and git-ftp will only upload the files marked with Git - and only if they have changed.
The downside is that you are going to have to learn Git - and that's a bit overkill for what you need.
The upside is that you are going to learn and use Git.
从那时起,我偶然发现了一个 Vim 插件,它可以与 Transmit 一起使用(我碰巧用作我的主要 FTP 客户端),并允许我在编辑时使用简单的键盘映射 (Ctrl+U) 将当前文件上传到服务器。
这在非常简单的解决方案和能够满足我显着提高工作效率所需的功能之间取得了很好的平衡。
仍然欢迎更多建议!
I have since stumbled upon a Vim plugin which works with Transmit (which I happen to use as my main FTP client) and allows me to upload the current file to the server with a simple keymap (Ctrl+U) as I edit.
This strikes a nice balance between being a very simple solution, and one that does enough of what I need to improve my productivity significantly.
Any more suggestions are still welcome!