sponsor Vim development Vim logo Vim Book Ad

basic Tip #581: Using vim to view source and edit textarea in mozilla/firebird

 tip karma   Rating 118/35, Viewed by 6990 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   October 8, 2003 21:56      complexity:   basic
author:   [email protected]      as of Vim:   5.7


This is the feature I have dreamed for months, please refer to
http://mozex.mozdev.org

 rate this tip  Life Changing Helpful Unfulfilling 

<< Switching back and forth between ViM and Visual Studio .NET | Quick way to write to your file. >>

Additional Notes

[email protected], October 9, 2003 1:45
The current version 1.07 does not work quite as it sounds.

I opened the Mozilla mail and the vim is not launched when composing a message.

When Viewing the page source or edit textarea, it reports an error: temporary directory c:\windows\temp does not exist.What the heck is this? it certainly does not exist on any PCs which do not have windows98 installed, neither does it exist on PCs which do not have the system installed on drive c:

The 'standard' temp directory should be %systemdrive%\winnt\temp. While user may specify their preference of temp directory in environment variable %temp%.

What is more, I found problem uninstalling this plugin...

[email protected], October 9, 2003 10:18

It works great for me on my W2k box.

Assuming that
1. gvim.exe is located at C:\vim\gvim.exe
2. temperoray directory is C:\tmp

Following is the setting in my user.js:
////////////////////////////////////////////////////////////
user_pref("mozex.command.source",   "C:\\vim\\gvim.exe %t");
user_pref("mozex.command.textarea", "C:\\vim\\gvim.exe %t");
user_pref("mozex.general.tmpdir", "C:\\tmp");
////////////////////////////////////////////////////////////

Note that mozillaFB plugin uninstall is still buggy,
and that is why I only have one plugin installed.


[email protected], October 9, 2003 20:38
So, is there any alternative way to safety remove the mozex plugin?

[email protected], October 9, 2003 21:05

To remove firebird plugin, I guess the best way for now is to  wait for official release of Firebird 0.7 and install from the beginning. You can also try grep "mozex" in your profile directory and edit one by one.
I believe future Firebire will have a solid uninstallation feature.

Also, I put a request on mozilla site for a builtin vim-view-source support:
http://forums.mozillazine.org/viewtopic.php?t=28677

Please back me up if you want such a feature, to put together the two best applications (vim and mozillaFB)  in the world. Thanks.
[email protected], October 9, 2003 23:33

Just found that we can vote for this bug ("allow external source viewer/editor"):
http://bugzilla.mozilla.org/show_bug.cgi?id=172817

If enough votes are gathered, then I guess we can use vim to view source in mozillaFB!

[email protected], October 10, 2003 6:05
The problem in MozillaFB is less serious than that in Mozilla (brower), in mozilla, you wil be unable to edit the textarea, nor view the source page, whether you want to use vim or not.  

sitar {at} procaut <dot> sk, October 21, 2003 7:20
I have installed Mozex into Mozilla
In browser window I can right-click and select Mozex->view page source
I get a Vim window with a page source. MAGNIFICENT!

However I could not start Vim from inside Mozilla mail.
How do I do it?

I was hoping that vim fires up whenever I jump into the text composing area
for mail. No luck here

No luck with Thunderbird either.

Stano
[email protected], June 1, 2004 16:01
I'm writing this tip from Vim right now.

Setup is Windows XP, Firefox 0.8, Vim 6.2.

Download & Install latest mozex from the url mentioned above ( http://mozex.mozdev.org/ ).  After it's installed, go to Tools, Options, Extensions.  Select Mozex and select Options.

My temp directory is "C:\temp", so that's what I entered in the "Directory for temporary files" field.
Vim is located at "C:\Program Files\Vim\vim62\gvim.exe" on my system.  However, mozex isn't handling its input in a very graceful way yet.  Thus, spaces trip it up.  The solution (which can be found on the Mozex site) is to use DOS short filenames.  Thus the path becomes "C:\Progra~1\Vim\vim62\gvim.exe".  We also have to pass an argument to vim so that it knows what to edit.  "%t" is the argument for editing source and textareas so the input for both fields is "C:\Progra~1\Vim\vim62\gvim.exe %t".

I don't think you can use Vim for mail, as the mail function passes many more options than the body text.  Check Mozex's argument list though ( http://mozex.mozdev.org/arguments.html ).  I'm not a vim hacker, just a vim user.  Perhaps someone with more experience could get vim to edit e-mails.
[email protected], June 7, 2004 21:09
     It works for me:  Mozilla 1.6 on Linux (Fedora Core 2).  I am using it
now.  Remember to click in text area after :w from vim!

     Here are my settings:
Intercept clicks:  mailto (maybe I'll add ftp later)
Mailer: gnome-terminal -x mutt mailto:%A?subject=%S&cc;=%C&body;=%B
Source: /usr/local/bin/gvim %t     (full path may not be needed)
Textareas: /usr/local/bin/gvim %t
Download: when does this apply?
[email protected], October 7, 2004 5:35
I want to use mozex for edit textarea on hungarian pages, but ő will be q and the same is with ŐűŰ characters. Can I edit unicode text with gvim and mozex?

Arpad
[email protected] (delete 'a's to reply), February 9, 2005 1:09
My firefox theme (chrome) has a browser.jar file with a BrowserViewSourceOfURL(url, charset, pageCookie) function.  It looks like a good place to put code to spit things out to a tempfile and open vim.  If Firefox does not stop this for security reasons.  Of course I don't really know what I'm doing, or I'd have done it or decided that it makes no sense.  Comments?
Anonymous, February 14, 2005 14:35
https://update.mozilla.org/extensions/?application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
I haven't tried this yet, but it should view source in whatever editor you want.

Neal
[email protected], July 28, 2005 12:21
See also this Firefox extension:

   ViewSourceWith 0.0.7.2, by Davide Ficano, released on July 25, 2005
   https://addons.mozilla.org/extensions/moreinfo.php?id=394
Anonymous, July 20, 2006 8:22
Another use of this is to put vim up inside your screen session. I'm running on cygwin, so screen is slightly broken, but this works for me.

screen -X screen /usr/bin/vim $@
sleep .2 # ugly hack due to mozex deleting the file as soon as the screen process finishes (just before vim reads it)

put that is a script file (~/bin/screenvim maybe) and set the textarea option as follows:

c:\cygwin\bin\bash.exe "c:\home\me\bin\screenvim" %t

Et viola.
[email protected], November 26, 2006 10:46
Unable to open the temporary file. Chech the temporary directory setting

That is the message I receive over and over again although I re-installed TB several times, cleaned the win/temp file, and I have enough space on my hard.
How can I make it work again?
Monica
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo