• You are not logged in.

Colemak + Vim

  • Started by Jules
  • 148 Replies:
  • Reputation: 0
  • Registered: 31-Aug-2006
  • Posts: 7

Hello,

The first thing I'll say is: Colemak is great! Thanks Shai for creating it.

I do have one problem though: how to use it with Vim? I've read that Shai uses Vim somewhere in the fora (correct?), and I'd really like to know how to remap the keys for Colemak.

Thanks in advance,

Jules

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

Update: Sublime Text is now my main editor. When I use vim, I use with it with the default keymap. No further updates are planned for colemak.vim

I'm a big fan of the Vim editor, and it is also great for ergonomic reasons. For a very long time I've been working on a completely redesigned keyboard mapping for Vim.

Some of the features:
* The navigation with it is much more intuitive and comfortable, using the IJKL keys (QWERTY), instead of the classic HJKL.
* Turbo navigation: holding the shift key while pressing the IJKL keys (QWERTY) is like pressing five times the key. It's really comfortable once you get used to it.
* Navigation in insert mode: holding the Ctrl key while pressing UIOK (QWERTY) is like the arrow keys.
* Easy word navigation using U/O/P keys (QWERTY).
* Easy PageUp/PageDown using the Y/H keys (QWERTY).
* The undo/cut/yank (copy)/paste correspond to the ZXCV keys.
* Tab replaces Escape to switch back to command mode (press Shift+Tab for a normal Tab).
* Visual mode/Replace/Insert/Append are are all in the home position on the ASDF keys (QWERTY).
* (GUI only) Intuitive support for tabs, Ctrl+T opens a new tab, Ctrl+W closes tabs. Ctrl+Tab switches tabs.
* (GUI only) Quick line reordering (holding Ctrl+Shift+up/down).
* Easy cursor history using ( and ).
* Whitespace/deletion keys work in both insert and command modes.
* Easy macro record and playback (qq to start recording, q to end recording, Q to playback)
* Easy line jumping (- key)
* Easy indention using Space/Shift+Space/Shift+Tab in visual line/block mode.
* Insert/Add also work in Visual Line mode like they work in Visual Block mode.
* : commands can be typed using a ; without holding shift (e.g. :wq can be typed as ;wq)
* (GUI only) Ctrl+C/Ctrl+V can copy and paste on the command line (selection must be done with the mouse)
* (GUI only) Ctrl+C/Ctrl+X copy/cut the current line if nothing is selected

I've been using it for the last few months and I'm very happy with it, but it should still be considered experimental. The documentation is embedded inside the Vim file, so it might take a little while to figure things out. That said, it is much more intuitive than the Vim mapping.

It is _very_ different from the normal Vim and it will take some time to used to it. There is some functionality that had to be sacrificed.

Download colemak.vim (experimental, requires Vim 7.0 or later, gVim recommended)

It would be great if someone would be able to create a graphical cheat sheet/tutorial for colemak.vim like this one.

Offline
  • 0
  • Reputation: 0
  • Registered: 31-Aug-2006
  • Posts: 7

Thank you, this is great!

I'll try to figure out how to create such a cheat sheet once I've mastered the keys.

Offline
  • 0
  • Reputation: 0
  • Registered: 05-Aug-2006
  • Posts: 1

Hi,

I use Colemak and Vim, and I think Colemak fits Vim very well after remapping only a few keys. I think the resulting normal mode layout is at least as good as - perhaps even better than - the Qwerty layout, although Vim was designed for Qwerty(!).

I've remapped Colemak `j' `k' `h' (`l') (i.e. Qwerty YNHU) to perform the Vim `h' `j' `k' (`l') commands.  Thus, Qwerty H is up and N is down, which I find very convenient since Qwerty H is placed just above N, and both are easy to reach. Qwerty Y moves left, which I find adequate since Qwerty Y is just left of U, and U moves right. However, I find Qwerty Y hard to reach, but this is not an issue since Colemak remaps Backspace to Qwerty Caps-Lock, which also moves the cursor left, and Caps-Lock is easy to reach.

Fortunately, none of these remapings cause any conflicts with standard Vim commands. (If they had, I'm not sure I would have choosen Colemak...  But I probably had :-))

Please find below my Vim-for-Colemak remappings.

Best regards, Magnus

" Remapping for Colemak
" ----------------------

" This remaps the movemet keys j and k (In Colemak, J (= Qwerty Y) is placed 
" above K (= Qwerty N), which I find confusing in Vim since j moves down and k 
" up. I think the remappings below result in a more logical and easier to 
" reach layout, keeping in mind that space and backspace (= Qwerty Caps-Lock) 
" can be used instead of Colemak J (= Qwerty Y). I use the join-lines command 
" much more than the help command, and have therefore swapped J and K since I 
" find Colemak K (Qwerty N) much easier to reach than Colemak J (Qwerty Y).

" The first five mappings are basically all one needs to remember.

noremap K J
noremap J K

noremap h k
noremap j h
noremap k j

noremap gh gk
noremap gj gh
noremap gk gj

noremap zh zk
"zK does not exist
noremap zj zh
noremap zJ zH
noremap zk zj
"zJ does not exist
noremap z<Space> zl
noremap z<S-Space> zL
noremap z<BS> zh
noremap z<S-BS> zH

noremap <C-w>h <C-w>k
noremap <C-w>H <C-w>K
noremap <C-w>j <C-w>h
noremap <C-w>J <C-w>H
noremap <C-w>k <C-w>j
noremap <C-w>K <C-w>J
noremap <C-w><Space> <C-w>l
noremap <C-w><S-Space> <C-w>L
noremap <C-w><S-BS> <C-w>H
Last edited by LeoMaheo (24-Sep-2006 10:42:51)
Offline
  • 0
  • Reputation: 0
  • Registered: 31-Aug-2006
  • Posts: 7

I'm still trying to figure out how to create cheat sheet.

I have a question about colemak.vim first:

How do you use d (delete)? You can't do dy for example: you have to use dw to delete a word. Is this a bug?

Thanks!

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

If you want it to work that way you can replace the "nnoremap"s with "noremap". I didn't test it out so it might have some unexpected side effects.

Offline
  • 0
  • Reputation: 0
  • Registered: 31-Aug-2006
  • Posts: 7

Thank you. Is there a reason for the current behaviour? Is this easier to use if you already have Vim experiece for example?

Offline
  • 0
  • Reputation: 0
  • Registered: 09-May-2007
  • Posts: 17

I've been using colemak.vim for a few days now, and have more or less grown used to it. However, as I much prefer using split windows over tabs, the heavy emphasis on tabs is quite annoying. Some points:

* :edit, :help get overwritten as :tabedit, :tab help respectively.
* C-w gets mapped to CloseWindow, which and the original C-w functionality (window pane manipulation) is mapped to gW instead, which is extremely painful to use.
* The alternative to C-w, :wincmd, doesn't understand the remapped direction keys.
* Using a/A/C-v for the various visual modes is disconcerting.

I have a feeling that I might be more comfortable doing a :noremap from Colemak to Qwerty so I can use qwerty bindings for all the commands.

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

Tabs are pretty much the norm in most applications these days, but I'll consider making the tabs functionality optional for the next version. In the meanwhile just comment out these lines. The C-w functionality is remapped to gW in colemak.vim.

There are in fact four commands for visual selecting in Colemak: Visual (A), Visual Line (Shift+A), Visual All (Ctrl+A) and Visual block (Ctrl+B, but Ctrl+V also works under Linux). It was designed so you would be able to use Ctrl+B (which is a logical shortcut for Block selection) across all platforms. Under Windows Ctrl+V is used for paste.

Ctrl+A is a standard shortcut for select all, and Ctrl+W is a standard shortcut for close window. colemak.vim was designed to be compatible with the standard keyboard shortcuts. The visual mode keys were put on the home row, because they are frequently used.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-May-2007
  • Posts: 17

Yeah, I've already commented out the "tab by default" alias, since they have rather little to do with  colemak.

I also made a typo - I do realize that C-b is for block selection... I suppose that just using "a" for visual mode is a little disconcerting after using the key for appending all these years.


Nonetheless, my problem with C-w functionality still stands. "gWj" is rather disconcerting... since "j" no longer maps to "down" in other modes... On the other hand, navigation between split panes has always been clumsy in vim...


And  I am still quite torn between using colemak.vim, and simply :noremap-ing back to QWERTY for command, operator-waitng and normal nodes, with Colemak only used for insert mode. I still quite like using the tab key to switch modes, and the movement keys seem a little more memorable than the traditional vim bindings.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-May-2007
  • Posts: 17

... and after looking at colemak.vim again, as well as some earlier debate in this thread... I noticed (slow!) that the directional keys only get remapped in Normal and Select modes - but not operator pending!

The current movement key mappings are only for Normal mode and Visual mode. I can understand that we don't want these mappings in Insert and Command mode, but I see no reason why there would be any conflicts in Operator pending! I'd go so far as to say that NOT mapping the movement keys in operator pending mode is a bug.

Select mode, though, is a little trickier. From what I understand, pressing character keys in this mode causes an immediate switch to insert mode, so it is probably best to not map the keys. This is probably why nnoremap is a also less than perfect.

The solution I have chosen is to add onoremap entries to all of the basic movement keys. This works out fine in general (eg dw, db, yw, and so forth), but doesn't work for window pane management. Window pane management doesn't appear to use operator pending mode, unfortunately - the sequences are all "hard coded" as such, and will probably require a major overhaul to work!

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

I've updated colemak.vim according to some of your suggestions.
I've added onoremaps, so everything should also be remapped correctly also in operating pending mode.
Window pane management is now remapped to <C-r> (was <C-w> in the original Vim), and it handles the direction operator correctly.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-May-2007
  • Posts: 17

Thanks Shai. Seems to be working out well for now.

# Of course, there are still small issues regarding personal preference that I'll have to resolve myself.
# Like mapping c[hange] to gc (making it a sort of second class citizen!)

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

I've made c[hange] a first class citizen again, it is now remapped to the w key.
Note that I've left the comma key intentionally unmapped so that you can remap it according to your preferences.

Offline
  • 0
  • Reputation: 0
  • Registered: 17-Apr-2007
  • Posts: 11
Shai said:

I've made c[hange] a first class citizen again, it is now remapped to the w key.
Note that I've left the comma key intentionally unmapped so that you can remap it according to your preferences.

Change was one of the things I was looking for.  Just need a good mnemonic for it now.  I'm thinking "wipe" at this point.

One small thing I miss is ciw (change inner word)...  with the remapping I don't know how to do something like that inner (i).  On the other hand, lwy (left to beginning of word, wipe word) isn't that bad of a compromise now that those keys are so close, but that doesn't help with other places where inner is useful in the motion.  Any thoughts on the "inner" and "a" motions?  (help v_a or help v_i for reference)

Offline
  • 0
  • Reputation: 0
  • Registered: 18-Jun-2007
  • Posts: 2

What's the justification for this section in colemak.vim?

" Tab behavior in the command line
cnoremap <Esc> <C-c>

I noticed that this section broke editing and command-line history browsing when using vim on a text console. (The arrow keys are escape sequences, and the initial Esc was being trapped and dropping vim out of command-line mode.)

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

WorldMaker, I've never really used the ciw functionality, but I can see it being useful. I'll try to find some elegant way to add it for a future version.

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

Therax, I think I left that line by mistake while testing something. I've updated colemak.vim to remove that line.

Offline
  • 0
  • Reputation: 0
  • From: Seattle, WA
  • Registered: 25-Aug-2007
  • Posts: 1

I learned to use vim with colemak before I found this forum, and I've already made a cheat sheet for the default command layout. I'll try out colemak.vim and if I like it maybe get around to making a cheat sheet for that too.

http://asicreateorder.com/pub/vi-vim-ch … et_col.gif
http://asicreateorder.com/pub/vi-vim-ch … et_col.svg

Offline
  • 0
  • Reputation: 0
  • From: Switzerland
  • Registered: 10-Nov-2007
  • Posts: 16

abbreviations used:
PREV: move line up by keeping the column
NEXT: move line down by keeping the column


Suggestions how to use vi (no remapping) with Colemak

vi can not be remapped with .vimrc, it would be necessary to recompile vi for this.

alternative moving in vi:
h = move char left: h is already the same key as with qwerty (alternative but worse: backspace).
l = move char right: Instead of this one can use the key Space which does exactly the same.
k = PREV: Instead of this one can use Ctrl-p. The key - is even harder to reach as k and does not keep the column.
j = NEXT: Instead of this one can use Ctrl-n. Ctrl-m and the key Ret are slightly different as they move to the first non blank of the next line. The key + would do the same but is even harder to reach.

Unfortunately these alternatives are not mentioned on most of the vi cheat sheets and vi introductions.


Suggestions how to use Vim and Emacs viper-mode with only a small remapping for Colemak

Unlike most others in this thread I prefer to remember and keep the original mnemonic and don't worry about the physical layout with regions and neighborhoods. I also want to keep beeing familiar as much as possible with vi (which can not be remapped with .vimrc) and less to be comfortable with Unixes on which you have only vi but no Vim out of the box like Solaris.

PREV on the key k and NEXT on the key j annoys me with vi in Colemak. Simply swapping n <-> j and p <-> k brings NEXT and PREV to Colemak-n and Colemak-p. This way NEXT comes back to the same key it was on qwerty-j (!) and the keys n and p are already used the same way for moving up and down in e. g. bash and Emacs, see summary below. The costs for these two swaps are that "Paste" moves from p to k and "search Next" moves from n to j. I appreciate these two swaps now for years.


Summary of line movement keys

up / down  |  tool and functionality
-------------+------------------------
C-p / C-n  |  bash history of command line
M-p / M-n  |  Emacs history of minibuffer (find-file, grep-find, compile, find-tag, ...)
    p /    n  |  Emacs dired-mode, buffer-list, ...
C-p / C-n  |  Emacs PREV/NEXT in buffer editing without viper-mode
C-p / C-n  |  Emacs PREV/NEXT in buffer editing with viper-mode if remapped for Colemak or not
    p /    n  |  Emacs PREV/NEXT in buffer editing with viper-mode if remapped for Colemak
C-p / C-n  |  Vim PREV/NEXT alternative keys, first of all if p/n not remapped for Colemak
    p /    n  |  Vim PREV/NEXT common keys if remapped for Colemak
C-p / C-n  |  vi PREV/NEXT alternative keys, first of all if p/n not remapped for Colemak
    k /     j  |  vi PREV/NEXT common keys (not remappable without recompilation)
C-p / C-n  |  GNU Screen selection in list of terminal sessions (C-a ") alternative keys
    k /     j  |  GNU Screen selection in list of terminal sessions (C-a ") common keys
    k /     j  |  less common keys
    y /    e  |  less alternative keys (easier for Colemak)
C-p / C-n  |  less alternative keys (easier for Colemak)


Colemak remap code for Vim in ~/.vimrc

" vim nnoremap for emacs-like next line for Colemak layout
nnoremap n j
nnoremap j n
" vim nnoremap for emacs-like previous line for Colemak layout
nnoremap p k
nnoremap k p

Colemak remap code for Emacs viper-mode in ~/.viper

;; vim nnoremap for emacs-like next line for Colemak layout
(define-key viper-vi-basic-map "n" 'viper-next-line)      ; was "j"
(define-key viper-vi-basic-map "j" 'viper-search-next)    ; was "n"
;; vim nnoremap for emacs-like previous line for Colemak layout
(define-key viper-vi-basic-map "p" 'viper-previous-line)  ; was "k"
(define-key viper-vi-basic-map "k" 'viper-put-back)       ; was "p"

edit: added all but the first section, Vim/vi alternative keys, link to bash changed

Last edited by cisum (17-Nov-2011 18:22:21)
Offline
  • 0
  • Reputation: 210
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,343

I'm starting to learn Linux and Vim now. About time I guess - I already have a scruffy beard and an extensive thesaurus of Monty Python quotes.  ;)

My first thought was that the navigation block is clumsy. Shai has a better suggestion but what I'd really like to do is use the WARS block. That's what I've navigated with in more games and other virtual environments than I can easily recall. Why not use it?

As I see it, append is a silly command and should by rights be assimilated into i (the A command would have to go elsewhere I suppose, so we can use the great 5-at-a-time navigation with Shift which I also recognize from games!). The W and RS commands could be moved too without me shedding a tear. Anyone feel differently?

I'm new at this and I'm open to good suggestions - just throwing out my thoughts for informed feedback.

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

Moving it to WARS would break to many things in the design of colemak.vim.
It is designed, for example, that cut/copy/paste/select would be in a different hand to the navigation keys.
To use WARS you either need to use the index finger for up and down, which is quite awkward, or you need to move your hand one key to the left off the home position.
Also, for the "turbo mode", where you hold the shift key. Most people find it more natural to use the left shift than the right shift. And it also allows to make less changes compared to original Vim and make things a bit more logical (e.g. R - Replace, S - inSert). Using the colemak.vim navigation keys isn't much different from using the arrow keys on the right.
Keep in mind that there are more navigation around the UNEI block, such as word back and word forward on L and Y, page up and page down on J and Y, etc.

Offline
  • 0
  • Reputation: 210
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,343

Thanks for those answers. This is going to be fun at some point, I can tell.

Did you say that the navigation blocks are different in normal and insert mode? Wouldn't it make sense to keep the main nav keys the same, only adding Ctrl- in insert mode?

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

It would be much more logical. Unfortunately, Vim can't differentiate between Ctrl+I and Tab. If I'd remap Ctrl+I the Tab key wouldn't work.
So as a compromise I use an inverted T shape for navigation in insert mode, which is still quite intuitive, but inconsistent for the left and right movements. Note that in the original Vim mapping there's no easy way to do that besides using the arrow keys to navigate in insert mode.

Since you can't remap under the Linux console Ctrl+S, and Ctrl+S is a shortcut that is commonly used for saving files, moving the navigation keys to the left hand (WARS or FRST) wouldn't solve that problem.

If you prefer, you could also remap the Alt (Meta)+N/E/I/U so it would work in insert mode the same way it would in normal mode.

Offline
  • 0
  • Reputation: 210
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,343

Alt/Meta-UNEI sounds like the better option, unless that messes up something important.

I cannot remap it myself since I don't have the skills for that kind of thing yet. It'll come to me, but slowly.

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0