在 VIM 中保存时的 RSync [英] RSync on save in VIM

查看:66
本文介绍了在 VIM 中保存时的 RSync的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种映射 :w 命令的方法,以便在我使用它时,它将 rsync 当前目录并保存有问题的文件.理想情况下,rsync 命令生成的响应应该在 vim 中返回,而不是在当前文件中,而是作为工具提示或其他东西.

I'm looking for a way to map the :w command so that when I use it, it will rsync the current directory and save the file in question. Ideally, the response generated by the rsync command should be returned in vim, but not in the the current file, but rather as a tooltip or something.

我设法在 TextMate 中实现了这一点,现在我希望开始使用 Vim.我一直在尝试诸如 :map w :w|!rsync 之类的东西,但这似乎不起作用.

I managed to achieve this in TextMate and am now looking to start working with Vim. I've been trying things like :map w :w|!rsync, but that doesn't seem to work.

推荐答案

您可以挂钩 BufWritePost.我不记得确切的语法,但:he BufWritePost"和:he autocommand"应该对你有帮助.

You can hook into BufWritePost. I don't remember the exact syntax, but ":he BufWritePost" and ":he autocommand" should help you.

你设置了一个像这样的基本钩子(模式匹配文件,所以你可以做 *.your_extension):

You setup a basic hook like this (pattern matches on a file, so you can do *.your_extension):

 :au BufWritePost * !rsync

另外,应该有一些方法可以使它成为缓冲区本地.

Also, there should be some way to make it buffer-local.

这篇关于在 VIM 中保存时的 RSync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆