[lug] Vi notes

Aaron Crane aaron.crane at pobox.com
Fri Nov 10 18:19:37 MST 2000

Hi, Chris.  Hope all is well with you these days.

Chris Riddoch <socket at peakpeak.com> writes:
> I use a dvorak keyboard layout.  There's some macros for mapping the
> qwerty keys to dvorak that come with vim, but the *real* problem is that
> 'hjkl' just isn't in the same place on a dvorak keyboard.  Any ideas?

The difficult bit is in deciding how you want the keyboard to behave.  One
possibility would be to invent some sane arrangement of the standard vi
commands on the Dvorak keyboard, and train your fingers appropriately
Another option, certainly easier and perhaps better, would be to arrange
your keyboard so that for vi's command mode, your fingers hit the same keys
as they would under the standard mapping for Qwerty.  So instead of hjkl to
move around, you'd use dhtn.

When doing this with vi, you need to make sure that your key mappings are
not scanned for further mappings, using the "noremap" family of commands.
To affect only the command-mode mappings, use the :nnoremap command.  For
example, the home row of the right hand is "hjkl;" in Qwerty, and "dhtns" in
Dvorak.  So we would execute the following commands:

    :nnoremap d h
    :nnoremap h j
    :nnoremap t k
    :nnoremap n l
    :nnoremap s ;

    :nnoremap D H
    :nnoremap H J
    :nnoremap T K
    :nnoremap N L
    :nnoremap S :

It's worth mentioning that typing these commands into a running vi will
probably cause you some serious problems.  Put them all in a file and source
them; when everything's working fine, you can add them to your .exrc or

You may also want to alter the bindings for operator-pending mode (so that,
for example, you can type Dvorak "e," == Qwerty "dw" to delete a word,
instead of Dvorak "ew").  To do this, just repeat the above commands using
:onoremap instead of :nnoremap.

This whole idea would be best if you've previously learnt vi on a Qwerty
keyboard; if not, it might seem a little pointless to have learnt Dvorak but
train your hands' editing gestures for Qwerty.  Also, it isn't very well
tested (I don't use Dvorak myself) so you might want to let me know how well
it works.

> Vi is, in my opinion, perfect for the quick-change to a configuration file
> and edits of that nature.  I'd be more likely to use it if there is a way
> to do the equivalent of Emacs' fill-* functions.  I suppose I shouldn't
> expect it to be a *part* of vi, since that rather goes against the
> philosophy designs of vi, so I'll ask it this way: Is there a filter-type
> program that does the equivalent of the fill-* functions?

Well, !}fmt in command mode refills the following paragraph.  In Vim, you
can also do gqip to refill the current paragraph.  I know some people who

    map Q gqip

in their .vimrc, making shift-Q the equivalent of M-q in Emacs.  I seem to
recall that it also works handily for mail messages quoted with ">", just
like with filladapt-mode in Emacs.

Aaron Crane   <aaron.crane at pobox.com>   <URL:http://pobox.com/~aaronc/>

More information about the LUG mailing list