share
Stack OverflowMaking Vim ubiquitous?
[+123] [28] Hamish Downer
[2009-05-05 18:13:00]
[ vim productivity vi ]
[ http://stackoverflow.com/questions/826208/making-vim-ubiquitous ] [DELETED]

The Pragmatic Programmer [1] recommends that you should use one text editor for everything. My chosen weapon editor is Vim.

So I want to collect all the ways in which Vim (and the Vim keybindings) can be used and setting up your computer to make Vim work well. This includes how to embed Vim in your IDE, web browser, email client, command shell ...

But I don't want Vim tips - there [2] are [3] other [4] questions [5] for them. I want tips to get into Vim, or Vim mode. Though tips about Vim mode not in an editor would be allowed (e.g. tips for vi mode when using Bash).

Update: Going quite well so far, with ways to edit in Vim/gVim, or to get vi mode in Firefox, Safari, Thunderbird, many IDEs and command line applications, MS Outlook and Word. But I'm wondering if there are more. Particular applications I wonder about include

(2) See also: stackoverflow.com/questions/1697214/… - Ryan Edwards
github.com/jakub-m/vim-in-textarea , adds VIM flavour to textareas (working but not mature, though) - Jakub M.
There is a nice plugin for firefox and chrome that allows you to use VIM bindings to edit any text area... it is called "wasavi" - AhHatem
[+55] [2009-05-05 18:22:52] chaos

Put this in your ~/.inputrc:

set editing-mode vi

That gets you vi mode in everything that uses readline (e.g. mysql client).


(6) Is this similar to set -o vi ? - OscarRyz
(4) Yeah, it does what set -o vi does in bash to whatever uses readline. - chaos
(1) I'm sorry, as die hard fan of vim as I am, there is no beating emacs shortcuts in this one. e.g. I do a $vi<Ctrl-P> and I can go back in history to all my earlier vim uses. or $kpdf<Ctrl-P> and all earlier uses, as opposed to typing esc for every shortcut and then using k and then pressing i to make changes. - user247077
(1) Damn, do I wish this was available in Windows. - Don Reba
(3) @user247077, your particular example, C-p etc are trivial to bind in addition to vi keys. And all in insert mode what's the default for a new prompt in bash/zsh :) - progo
@DonReba You can install cygwin or something and then bash and you're good to go. - user247077
(2) Note that zsh does not use readline, but instead zle, which does not read ~/.inputrc. - orftz
1
[+22] [2009-05-08 00:54:46] andrewdotn

Trying to use vim for everything is overkill. While the book does say,

Tip 22

Use a Single Editor Well

at a high level, it also says “use the right tool for the job.” It’s better to know how to use one text editor really well than to be barely competent with a half-dozen; but it would be significantly worse to master only a single program.


2
[+21] [2009-05-05 18:15:01] Hamish Downer

For Firefox, It's all text [1] and ViewSourceWith [2] allow you to use an external editor for text boxes. You generally want to use

gvim -f

The -f option means that will not fork a process, so this allows the calling program to wait until gVim closes. Without the -f option the above plugins won't work very well ...

If you want to go further then investigate the vimperator [3]. Scroll pages with hjkl, go back and forward with H and L, and many more keybindings [4] familiar to Vim users.

It is not at version 1.0 yet, but jV [5] makes text areas work like vi.

And finally there is an experimental way to directly embed the actual Vim in Firefox using embedded editor [6] - though it requires mozplugger and will only work on Linux.

For more details see this question about using vim with firefox [7].

[1] https://addons.mozilla.org/en-US/firefox/addon/4125
[2] https://addons.mozilla.org/en-US/firefox/addon/394
[3] https://addons.mozilla.org/en-US/firefox/addon/4891
[4] http://vimperator.org/trac/wiki/Vimperator
[5] https://addons.mozilla.org/en-US/firefox/addon/8529
[6] https://addons.mozilla.org/en-US/firefox/addon/5482
[7] http://stackoverflow.com/questions/75652/is-there-a-firefox-add-on-to-use-vim-to-edit-textboxes

The main thing I don't like about It's All Text is that I can't find any way to launch the external text editor using the keyboard. What good is it if I have to use my mouse to launch the editor? - Chad Birch
(1) @Chad Birch: If you look at the preferences for It's All Text, you'll see there is a "Hot Key" preference that allows you to set a keyboard shortcut. I use Ctrl-E - Hamish Downer
(2) try vimperator & hit ctrl-i while in a text-area ;) - sjh
I couldn't get ViewSourceWith or jV to work with current versions of Mac OS X (Snow Leopard) or Firefox (15.0.1). - David Ketcheson
It's All Text doesn't work with latest versions either. The only thing I got working is QuickCursor, which works like It's All Text. - David Ketcheson
3
[+21] [2009-05-05 18:44:27] Steve Rowe

I can highly recommend ViEmu [1] which is a plugin for Visual Studio giving you nearly 100% Vim capability while retaining things like Intellisense. It's great for C# coding. There is also a version of ViEmu for Word, Outlook and for SQL Server if you do a lot of those and want the power of Vim there as well.

[1] http://www.viemu.com/

(3) For me, it seems kind of useless, since it does not support Vim scripts. That would be a dubious proposition, even if it was free. - Don Reba
4
[+18] [2009-05-05 18:19:41] Hamish Downer

When using Bash, you can do

$ set -o vi

to enable vi editing mode. You start in insert mode, but you can press Escape and go forward and backwards with h and l, delete the previous word with db (or dB for back to the previous gap defined by spaces) ... If you like it, stick

set -o vi

in your .bashrc file.

Also see this question about vi mode and readline [1].

[1] http://stackoverflow.com/questions/537522/standard-python-interpreter-has-a-vi-command-mode

(1) This is covered by adding 'set editing-mode vi' to .inputrc - graywh
(1) @graywh: it is, but sometimes you just want a temporary change.. Maybe you are ssh'ed into a server as root, and just want to change to vi-mode for that session, but not to change it for everyone else. Or you are on someone else's computer for a brief period. - Hamish Downer
5
[+14] [2009-05-18 16:29:28] sjh

For Firefox use Vimperator [1]. It transforms Firefox into a vim-like program.

Hit Ctrl-I while your keyboard focus is inside a text area to launch vim on that text area.

[1] http://vimperator.org/vimperator

(2) Being a Vim adept, I tried to use this multiple times over the years. However, the mapping of VI onto browser doesn't really make sense to me. I like the (e)links(2)/lynx/w3m type bindings a lot better. Opera is the king of keyboard browsing for me - sehe
6
[+13] [2009-05-05 18:13:53] Hamish Downer

For Thunderbird, the external editor [1] extension allows you to use gVim to write your emails, or you could use Vimperator [2]'s sister extension - muttator [3].

[1] http://globs.org/articles.php?pg=2&lng=en
[2] http://en.wikipedia.org/wiki/Vimperator
[3] https://addons.mozilla.org/en-US/thunderbird/addon/7162

7
[+11] [2009-05-06 06:32:07] sykora

Set your $EDITOR to Vim.

At least in Linux, most environment aware applications will draw on this variable to choose the editor whenever they need you to edit something.


8
[+10] [2011-07-18 19:07:43] user8958

dactyl [1]

is like vimperator but maybe even better (I just started using it a bit).

I'm no programmer but like using this way of browsing. I still wonder if it's worth my while getting more into vim, since I'll probably never write a program; a bit of basic command line use in the terminal is about it.

[1] http://dactyl.sourceforge.net/pentadactyl/

9
[+9] [2009-05-05 19:22:41] Brian Carper

Vim can be used as PAGER [1] and for viewing man pages [2].

Many tools, e.g. Git, also let you specify a DIFF program (often via a configuration option or environment variable); Vim's diff mode works very well for that.

[1] http://vim.wikia.com/wiki/VimTip121
[2] http://vim.wikia.com/wiki/Using%5Fvim%5Fas%5Fa%5Fman-page%5Fviewer%5Funder%5FUnix

10
[+9] [2010-04-25 21:46:14] Hamish Downer

For Google Chrome, there are now a few extensions. Text Aid [1] and Edit with Emacs [2] both allow editing with an external editor. (Edit with Emacs does not require you to use emacs).

And in the spirit of the Vimperator Firefox extension, there are now

allowing you to navigate pages with vi key-bindings. However currently (May 2010) they are very basic compared to the Vimperator. Vrome is the most feature rich one [6].

[1] https://chrome.google.com/extensions/detail/ppoadiihggafnhokfkpphojggcdigllp
[2] https://chrome.google.com/extensions/detail/ljobjlafonikaiipfkggjbhkghgicgoh
[3] https://chrome.google.com/extensions/detail/godjoomfiimiddapohpmfklhgmbfffjj
[4] https://chrome.google.com/extensions/detail/dbepggeogbaibhgnhhndojpepiihcmeb
[5] https://chrome.google.com/extensions/detail/donnjgnmaheadpiphiedimcjpiefdnnj
[6] http://github.com/jinzhu/vrome#readme

11
[+8] [2009-05-05 18:16:54] Hamish Downer

You can set your keyboard to swap Caps Lock and Escape.

With the standard Ubuntu/GNOME desktop, go through the menus: System -> Preferences -> Keyboard -> Layouts tab. Then hit the "Layout Options" button, click on the triangle next to "Caps Lock key behaviour" and select "Swap ESC and CapsLock".

Not strictly part of Vim, but it makes Vim so much nicer to use.

Also see this question about making the ESC key easier to get to [1].

[1] http://stackoverflow.com/questions/397229/reaching-up-to-hit-the-escape-key-sucks-especially-in-vim

I guess that this would be cool. But I tried it and now I know that I wouldn't survive the first three days. - innaM
Swapping is a bad idea because you end up hitting caps lock by accident instead of ESC. Better to get rid of the caps lock functionality entirely and have both of those keys produce an ESC. Unless of course you actually find caps lock useful. - intuited
@intuited: I do find caps lock useful once in a while. I never reach up to the ESC key normally. But I guess having both be ESC might be useful for people in transition. - Hamish Downer
12
[+6] [2009-05-05 18:16:56] Adrian Mouat

There are some Vim plug-ins for Eclipse, see http://www.vimplugin.org/.

There is also a commercial one at http://www.viplugin.com/viplugin/.

Also, Eclim is a layer that connects headless Eclipse to Vim, giving it code completion abilities, and an understanding of Eclipse projects: Eclim home page [1]

[1] http://eclim.org/

I'm a user of viplugin. It works but it's not great. However it's better than nothing. - Peter Severin
(1) It is frustrating that such a useful thread is closed. - Traveler
I found this very useful: stackoverflow.com/questions/4084114/… Amazingly, I can pop back and forth from Vim to Eclipse and everything seems to work. - Traveler
13
[+5] [2009-12-19 03:43:48] Pistos

To change zsh to vi mode:

bindkey -v

To change it permanently, add that line to your ~/.zshrc. Alternatively, if you set your EDITOR (environment variable) to vi or vim, zsh will assume you want vi mode in the shell command line as well.


14
[+5] [2010-05-17 17:57:29] Hamish Downer

There is a PDF viewer called apvlv [1] that uses vi-like bindings.

For example, < Ctrl-f > to forward page, < Ctrl-b > to previous page, 'k','j','h','l' to scrolling a page up, down, left or right, and so on.

And, Apvlv can understand that how many times you want to run the command.

The only thing you need to do is typing the number before the command. For example, typing '50' and < Ctrl-f > will go forward 50 pages, typing '30' and < Ctrl-b > will go previous 30 pages.

[1] http://code.google.com/p/apvlv/

(3) Just found out that evince (a PDF reader on Linux) lets you move around using hjkl aswell. - Hamish Downer
(4) And Okular as well. - progo
Zathura too - its primary interface is Vim-style commands. - Nathan Moos
15
[+4] [2009-05-05 19:52:42] Andy

I've seen quite a few examples around the web of Autohotkey being combined with gvim [1] in order to increase ubiquity. There are probably more.

[1] http://jamesoff.net/site/2009/04/03/using-gvim-to-edit-mail-in-outlook/

16
[+4] [2009-05-06 13:24:21] Hamish Downer

For Mac users I just came across the Vi Input Manager plugin [1] which "patches the Cocoa Text System to add a Vi-like command mode". This affects applications including "Safari, TeXShop, XCode".

Looks cool. (Though I am not a Mac user).

[1] http://www.corsofamily.net/jcorso/vi/

17
[+4] [2009-06-04 13:13:15] smcameron

For your Vim gaming needs: Word War vi [1] - a retro styled side scrolling shoot'em up arcade game for Linux.

[1] http://wordwarvi.sourceforge.net

18
[+4] [2010-05-17 17:44:13] dotancohen

Abiword has an optional VI mode:

http://recycledelectron.blogspot.com/2009/01/vi-and-emacs-key-bindings-in-abiword.html

How I wish that was available for OpenOffice.org:

http://qa.openoffice.org/issues/show_bug.cgi?id=89663

Please comment on that OOo bug!


19
[+4] [2011-01-16 12:33:38] Bitterjug

Here's an idea for a bit if hjkl ubiquity (based on this thread [1] at superuser.com) but sadly it doesn't work.

xev tells me that my Windoze key sends keycode 133; I created .hjkl.modmap:

keycode 66 = Mode_switch
keysym j = j J Left 
keysym l = l L Right
keysym i = i I Up
keysym k = k K Down

And installed it with xmodmap

$ xmodmap .hjkl.modmap

Now Win-[hjkl] behave like the arrow keys. One less reason to take my hands off the home keys. But it clobbers the Win key. Maybe someone knows how to just remap Win-h, etc?

[1] http://superuser.com/questions/213051/remap-arrow-keys-to-winijkl-on-linux

20
[+3] [2009-05-05 18:31:14] Hamish Downer

One last link to another question - this one about vi mode plugins for IDEs [1].

[1] http://stackoverflow.com/questions/294613/does-any-ide-have-a-vi-keybindings-options

21
[+3] [2009-05-08 04:09:02] Greg Dunn

This [1] site has an AutoHotkey script for Windows that will let you set up some basic Vim keystrokes in any application (I use hjkl for motion everywhere now).

[1] http://duartes.org/gustavo/blog/post/home-row-computing

22
[+2] [2009-05-05 18:56:06] Joe Philllips

In the game NetHack [1] you can use vi keyboard mode. Just set the setting to 0 (zero):

number_pad
Use the number keys to move instead of [yuhjklbn] (default 0 or off).
[1] http://www.nethack.org/

23
[+2] [2009-05-16 07:15:51] Caglar Toklu

MonoDevelop has a vi mode [1] too.

Also check Eclim [2]. It started to integrate the functionality of Vim and Eclipse, but now it seems it is beyond that. I have not used it though, but its release notes shows that it supports Python, PHP and C++ and markup languages.

[1] http://mjhutchinson.com/journal/2008/10/14/vi%5Fmodes%5Fmonodevelop
[2] http://eclim.sourceforge.net/

24
[+2] [2009-12-21 20:43:29] 0x89

There is a very good vim plugin for intellij idea (recently partly open sourced). It can easily be installed from the plugins menu.

And there is jvi [1] for netbeans.

[1] http://jvi.sourceforge.net/

jvi is the cream of the crop as far as IDE vi[m] plugins. All others seem a bit clunky. - Lyle
25
[+1] [2009-05-06 21:11:59] Hamish Downer

Just for completeness, I will mention that you can use command line email clients such as mutt [1] and pine [2]. And with them you can use any command line editor for writing your emails.

[1] http://en.wikipedia.org/wiki/Mutt%5F%28e-mail%5Fclient)
[2] http://en.wikipedia.org/wiki/Alpine%5F%28e-mail%5Fclient)

26
[+1] [2011-03-31 23:06:34] Sameer

Check out the IDE pida [1]. This embeds vim right inside the IDE. Standard features like interface with common version control software and source code browsing with ctags / gtags are included. Plugins are available for a variety of languages. You can also use this with emacs instead of vim.

[1] http://pida.co.uk

27
[0] [2009-07-08 10:50:51] Greg

I have half-followed the instructions at the Vim tips wiki [1] but used my own little script for AutoHotKey:

; edit in Vim...
#v::
WinGetActiveTitle, VimTargetWindow
SendInput ^a^c
RunWait c:\Program Files (x86)\Vim\vim72\gvim.exe --servername ClipBrd +ClipBrd +only
If not ErrorLevel
{
    WinActivate %VimTargetWindow%
    Sleep 10
    SendInput ^a^v
}
return

However, it does clobber the clipboard, and is a bit hit and miss whether it gets back to the right application if you've been doing things in the meantime...

[1] http://vim.wikia.com/wiki/Use%5Fgvim%5Fas%5Fan%5Fexternal%5Feditor%5Ffor%5FWindows%5Fapps

28