MacVim:打开 webview 或显示工具提示(如 TextMate)
我开始使用 VIM 并尝试稍微理解它。我目前使用 TextMate 进行 Web 开发,因此我可以构建很好的命令,这些命令可以快速获取当前文档/选择并显示为 Web 视图,或者通过工具提示发送一些结果。
我认为将这个问题提交给 MacVim 更合适,因为它可以访问 GUI 元素,所以有时可能是这样?
“命令的 HTML 输出”是一个很好的解释。
所以我想知道是否可以像 TextMate 一样将命令输出到 HTML 窗口?
或者我是否必须创建自己的程序来接受 STDIN 并将其显示为视图上的 html 输出?
工具提示也一样吗?
我希望 MacVim 能够访问 Cocoa 库和 GUI 元素,也许它已经拥有这样的功能了?
抱歉,如果我在这里误解了事情,我真的觉得迁移是个好主意,但显然我想保留我使用的漂亮而快速的工具,并且不失去良好的视觉吸引力。
I am starting on VIM and trying to understand it a bit. I currently use TextMate for web development, so I can build nice commands which take my current document/selection and display as a web view very quickly or send some results through tooltips.
I believe it's more appropriate to refer this question to MacVim since it has access to GUI elements so sometimes it might be possible?
"HTML Output for Commands" is a good explanation.
So I would like to know if it's posibble to output commands to a HTML window just like TextMate?
Or would I have to create my own program that accepts STDIN and display it as an html output on a view?
The same for the tooltips?
I was hoping that as MacVim is has access to Cocoa library and GUI elements perhaps it could already have some feature like this?
Sorry if I am misunderstanding things here, I really feel that it would be a good idea to migrate but obviously I would like to keep the nice and quick tools that I use and not losing a good visual appeal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以让 vim 在命令行发出一条命令,告诉浏览器打开您正在编辑的文件。
在 Mac 上,使用命令行中的 vim 或 MacVim,如果您正在编辑缓冲区中名为“test.html”的文件并且该文件位于您的桌面文件夹中:
将在浏览器中打开或重新打开该文件。因此,当您进行更改时,您发出该更改,浏览器将带着最新版本的文件来到前台。您可以使用其他选项“打开”来指定要使用的浏览器。并且,您可以轻松添加一个按键来打开当前文件,即命令行上的“%”。
如果你想捕获 vim 中命令的输出,有几种方法可以实现。如果执行命令,vim 会将其输出捕获到临时缓冲区中以供查看。
显示:
您还可以查看 MacVim 中的 Command - R 类似功能 和 Vim - 在新窗口中显示代码输出 á la Textmate?。
我不确定你所说的“工具提示”是什么意思。通常,这指的是鼠标尖端弹出的文本,提供上下文相关的帮助。您无法通过它发送文本,因此您对该词的使用令人困惑。
MacVim 和 vim 确实具有类似片段的功能,而且可以编写脚本,可以处理当前选择的文本,还有更多功能。重要的是要了解 MacVim 是常规 vim 编辑器之上的 GUI 层,因此有些事情它不会做,因为 vim 的引擎并不容易。这从来没有困扰过我,因为如果我需要特定的 TextMate 功能,我会启动它,使用那个特定的东西,然后如果我愿意就跳回来。但是,这对我来说并不常见。
您可能想在页面右侧查看一些相关的线程,另外还可以查看一些 vim 的插件,例如:
我一直用上面的。如果没有的话,我会想念以下这些。
编辑:
在 Vim 中将临时缓冲区捕获到新缓冲区非常简单:
第二行
:sil !ls -al
可以是任何执行命令。:sil
告诉 Vim 不要将输出回显到临时缓冲区,而是静默捕获它,从而摆脱“按任意键”暂停。:vnew
创建一个垂直分割,其中包含一个新缓冲区。如果您想要一个新选项卡,您可以使用:tabnew
来代替。"agp
告诉它使用缓冲区@a
并将输出粘贴到当前缓冲区中,并将光标保留在粘贴的文本下方。You could have vim issue a command at the command-line which would tell a browser to open a file you're editing.
On a Mac, using either vim at the command-line or MacVim, if you were editing a file called "test.html" in the buffer and it was in your Desktop folder:
will open, or re-open the file in the browser. So, when you make a change you issue that and the browser will come to the foreground with the latest version of the file. You could use the other options to "open" to specify which browser to use. And, you could easily add a key press to open the current file, which is "%" on the command line.
If you want to capture the output of a command in vim, there are a couple ways to do that. If you execute a command vim will capture its output in a temporary buffer for viewing.
displays:
You can also see what's in Command - R like functionality in MacVim and Vim - Displaying Code Output in a New Window á la Textmate?.
I'm not sure what you mean by "tooltips". Usually that refers to pop-up text at the tip of your mouse offering context sensitive help. You can't send text through that, so your use of the word is confusing.
MacVim and vim do have snippet-like capability, plus are scriptable, can work on text that is the current selection, plus a whole lot more. It's important to understand that MacVim is a GUI layer on top of the regular vim editor, so there are somethings it won't do because vim's engine doesn't make it easy. That hasn't ever bothered me, because if I need a particular TextMate feature I'll fire it up, use that particular thing, then jump back if I feel like it. But, that's not too common a need for me.
You might want to look at some of the related threads here on SO, over on the right hand side of the page, plus look at some of vim's plugins like:
I use the above ones all the time. The following ones I'd miss if I didn't have them.
EDIT:
Capturing the temporary buffer to a new buffer in Vim is pretty easy:
The second line
:sil !ls -al
could be any execution of a command.:sil
tells Vim to not echo the output to the temporary buffer, instead capture it silently, which gets rid of the "Press any key" pause.:vnew
creates a vertical split with a new buffer in it. You could use:tabnew
instead if you want a new tab."agp
tells it to use buffer@a
and paste the output into the current buffer and leave the cursor below the pasted text.