MacVim: Opening webview or displaying tooltips like TextMate
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.
so I would like to know if its posibble to output commands to an html window just like TextMate?
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:
:!open ~/Desktop/test.html
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.
:!ls
displays:
:!ls Desktop Downloads Library Music Photo Tools Public VirtualBox VMs bin Documents Editors Movies Music Tools Pictures Sites Web Tools
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:
- taglist.vim
- vimspell
- matchit.zip
- align
- surround
- Tabular
I use the above ones all the time. The following ones I'd miss if I didn't have them.
- Command-T
- SnipMate
- Rails.vim
EDIT:
Capturing the temporary buffer to a new buffer in Vim is pretty easy:
:redir @a
:sil !ls -al
:redir end
:vnew
"agp
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.
精彩评论