Hacker News new | past | comments | ask | show | jobs | submit login
Wasavi – a browser extension that transforms TEXTAREA elements into a VI editor (appsweets.net)
175 points by yankcrime on Feb 2, 2016 | hide | past | favorite | 42 comments



It’s worth a mention that although it’s not all that widely known, all native text fields under OS X come with a subset of emacs key binds built-in, and this includes web page text fields in Safari, Chrome, and Firefox so if you like emacs keybinds and run OS X you’re ready to go right out of the box, no need to install anything.

See http://jblevins.org/log/kbd for further detail.


If you're on Linux and running GTK-{2,3} applications, you can also have emacs key-bindings in your text entry fields (in firefox, nautilus, gmrun etc), with a small amount of work. See [1] for details.

Using the pre-defined emacs keybindings has the disadvantage that they override the normal (CUA), which is sometimes inconvenient (especially since AFAIK gtk doesn't allow you to use multiple-chord keybindings, so for example, C-x h is out). You can go around this by copying /usr/share/themes/Emacs/gtk-3.0/gtk-keys.css to (say) ~/.themes/my-new-theme/ and /usr/share/themes/Emacs/gtk-2.0-key/gtkrc into your ~/.gtkrc-2.0 and replacing all occurrences of <ctrl> with (say) <super> or <hyper>. For gtk-3 you then also need to run gsettings set org.gnome.desktop.interface gtk-key-theme "my-new-theme"

[1] http://askubuntu.com/questions/124815/how-do-i-enable-emacs-...


Thanks for sharing that! I'd never known that was the case. I do prefer vi bindings over emacs, but I can make do with these. This'll be just a little life-changing.


I've been using this for a few months. My favourite thing is that it supports `ex` commands, and if you have a cheap pedal from Deal Extreme or Alibaba or whatever, you can get your Vim toggle powers real easily. I programmed mine to emit `C-f` and did just this:

map <C-f> a

map! <C-f> <Esc>

It's not fancy, but it lets me toggle between Insert and Normal in a useful enough way.

One unfortunate thing is that being in Wasavi mode won't get your auto-save in Gmail, etc. I made that mistake once months ago and disabled it there ever since.

Very impressed by this software.


And for the rest of us, here's a Firefox extension that makes emacs shortcuts work in text areas or everywhere: https://addons.mozilla.org/en-US/firefox/addon/firemacs/

Unfortunately, many web apps assume the CUI bindings. Having to paste via Ctrl+V when you have remapped the paste hotkey everywhere is merely a nuisance. Not being able to use other webapp shortcuts because they are not defined in CUI but are taken in vim / emacs mode can be a show-stopper. (This is why I limited myself to remapping copy and paste only.)


Great, now I can choose which bullet to get shot with.

Coming up next, Edlin plugins


> Unfortunately, many web apps assume the CUI bindings

With some going even beyond that. If i use ctrl-pgup/pgdn while browsing G+, the press will both swith tabs and bump the G+ page up or down.

And over at Youtube, hitting home will set the video back to zero if it has "focus". And i have this habit of using home to get to the top of the page after scrolling down to read comments (yep, i hate myself).


Not directly applicable, but elinks[0] allows ^T (ctrl-T (capital 'T')) while editing a textarea to launch $EDITOR. It's really nice.

Edit: in some instances, it's incredibly useful. For example it makes some cases of gmail more usable/enjoyable than via Firefox. I get all the power of vi and full access to my running system, so I can easily inline code segments or log files into my messages, and not lose editor focus if I bump the mouse, etc :P

[0] http://elinks.or.cz/


Or mutt if that's where you are going. I can't tell you how many emails I've accidentally sent from the browser that end in :wq


Now I'm jokingly imagining running Emacs and "term" mode with mutt or elinks and running vi to do the editing. It sounds silly on the surface, but I think is a testament to the composability of the tools.

Edit: tested Emacs/elinks, and it works if the TERM is changed from eterm-color to vt100. Hooray for text and Unix.


What is the emacs for? I'm so confused.


Although the OP posted himself, one thing I try to explain to people who don't use Emacs very much is that instead of thinking of it as an editor with a Lisp extension language, it's better to think of it as a Lisp environment with a built in editor. And although people jokingly refer to it as an OS (and even the kitchen sink is included -- as an icon), it's really more like a shell. You have a windowing environment, you can integrate other programs including terminal shells, debuggers, etc, etc. Finally, because it is a full Lisp environment, you have 30+ years of accumulated Lisp programs that you can run (some of which have no equal on any platform).

I used Emacs for 20 years and while I've strayed away from it (got interested in Vim), I'm slowly making my way back. Not for the Emacs keybindings (which are fine), but for the entire elisp ecosystem. So in a way the OP's imaginings are not so far off (although I don't think you can actually run vim inside emacs -- you will need to use Evil mode instead ;-) ).


I used nvi on NetBSD, and indeed it did work if I set TERM=vt100 inside Emacs term (M-x term).

So:

  NetBSD$ env EDITOR=vi emacs
  (M-x term)

  Emacs$ env TERM=vt100 elinks news.ycombinator.com
(go to text area, start editing, ^T, and up pops (n)vi)

I'm a long-time Emacs user as well, but have found myself on vi for last few years, initially as a refresher. There's definitely still a place in my heart for Emacs, though. I think your characterization of Emacs is also fair; I usually describe it as a Lisp VM.

Edit: formatting for clarity(?)


I did say "jokingly imagining" above. "Emacs is a great operating system, lacking only a decent text editor."[0]

[0] https://en.wikipedia.org/wiki/Editor_war


Emacs can serve as a terminal multiplexer, which is the most obvious thing for Emacs to provide in that setup, though as mikekchar said, it does have a lot to offer.

I never quite got the people who run Emacs in screen/tmux; emacs can already do that!


Is there an emacs equivalent of screen -r? (or, if you want to be exciting, -x?)


Sort of. You can run emacs as a daemon and attach to it with emacsclient. Then when you want to detach, you just C-x C-c like usual, or disconnect and let the emacsclient process die. You have to remember to run emacs as a daemon up front, though.

You could also run emacs inside something like dtach or abduco [1], which are a "session managers" like screen or tmux but without the multiplexer.

http://www.brain-dump.org/projects/abduco/


Yes, I was referring to `emacs --daemon`/`emacsclient`.

If you run `emacsclient -a ''` then it will automatically run `emacs --daemon` for you (if it isn't already running), so that you don't need to run it up-front.


Nice, it even has a Javascript interpreter. I use w3m for various things, but the lack of Javascript makes it less than usable for a ton of stuff. The lack of configurable key-bindings also makes me sad.


When it works the JavaScript is limited. I've never gotten it to work.


I use pentadactyl with firefox which allows me to <C-i> in a text area which launches emacsclient (running in daemon mode) and sends the text back when I save. no mouse! Here is a short video of how it works: https://youtu.be/_ZoABZ8muy0 (huge gif http://imgur.com/iXMeZDj)


Perhaps I'm being too paranoid, but has this extension been externally vetted?

I'm reluctant to give access to all data I type in input boxes to a developer I'm not familiar with. While they claim it works only on textarea elements, what's stopping them from reading other input elements, including username / password fields? It seems like an awfully convenient credential collector.


Finally and extension that seems to work for me: it doesn't open external window and doesn't force me to save to make sure changes are populated back to the browser (i have easily multiple tabs with half written texts opened simultaneously). I would love for this to be available for Thunderbird as well. :wq :)


I've been using cVim for page navigation and Wasavi for editing text boxes for a while now and have been really happy with the combination. I still use an external editor for more involved edits/when I'm feeling paranoid, but Wasavi is great for just about everything else.


Presumably inspired by the similar post today doing this with Atom for Chrome.

https://news.ycombinator.com/item?id=11022356


It's All Text![1] has existed for almost a decade. The interesting thing about this addon is that the Vim UI is actually integrated in the browser.

[1] https://addons.mozilla.org/en-us/firefox/addon/its-all-text/


I'm testing my wasavi installation right now. It is great, but it doesn't have VISUAL mode.

But it has search and replace.


I have visual mode - pressing v and then moving the cursor to select text. I'm on Firefox on Ubuntu 14.04.


I'm sorry. I have it too, it is called BOUND mode. What I don't have is VISUAL BLOCK mode.


Doesn't seem to work on IPython Notebooks, unfortunately (maybe those fields aren't TEXTAREAs?).


This is great, one thing I'd like to do is map j and k to gj and gk to make it easier to move between wrapped lines. It kind of works in Wasavi but it doesn't seem to move directly above or below the previous position.


Ooh, this is like a newer and actually working Pterosaur. I was just now struggling to get that to work (it's been unmaintained for a year, so it's probably just broken), maybe I'll try this out instead.


Does :q! terminate the browser? That's the only vi command I know.


Ha. Nope—it exits vim mode.


Why not just use Vimperator?


For one, this is on-demand and doesn't rewrite the default keybindings of the browser. It is nice for anyone else using your browser where they can ignore it entirely. It's a tradeoff and each has their benefits.


I can't live without vimperator nowadays. It's the only thing stopping me from switching to Chrome from FF (and yes, i know there are other similar vi extensions for Chrome but none seem as good as vimperator for FF).


Does Vimperator allow for vi mode in textareas? I thought it was for general browser control.


Just tested this and Vimperator does allow vi mode in text areas if control+t is pressed. It's not as slick as wasavi but it works. There's also the option of launching an external gvim window when control+i is pressed inside a textarea, which is a cool feature for more in depth editing tasks.


Been using wasavi for quite a while now and really like it. The vim emulation is pretty dang good!


Yes, Vimium for chrome and Wasavi for the text boxes, makes life little more vim complete.


s/VI/vim/ in case you were wanting to use uu in a standard way




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: