Author Topic: Vim on non-QWERTY layout?  (Read 4673 times)

0 Members and 1 Guest are viewing this topic.

Offline wolfv

  • Thread Starter
  • Posts: 269
Vim on non-QWERTY layout?
« on: Tue, 09 April 2013, 21:53:16 »
I am a Vim user interested in using a Colmak or Arensito keyboard layout.
Would love to hear from people that have tried Vim on non-QWERTY layouts.

Is it possible to have the best of both worlds: Vim and a good keyboard layout?
I am leery of the hjkl vi arrow keys being off the home row.

Thank you for sharing your experience.

Offline oneproduct

  • Posts: 859
  • Location: Montreal, Canada
  • @Ubisoft
Re: Vim on non-QWERTY layout?
« Reply #1 on: Tue, 09 April 2013, 23:25:55 »
I had some trouble with this too when I first started to use Vim. At first I tried to remap everything, but in the end, I found something simpler. Surely you must know about WASD cursor movement on Qwerty? Another variation of that is ESDF, one set of keys to the right. This leaves your index finger on the homing bar on the left side of the keyboard. On Colemak, this would be FRST.

In Vim, R and S are quite similar, and both are similar to C. F and T are again both similar. Also, FTRS are somewhat less critical than other Vim functions (C can often do what R and S can do or you can use X or D paired with I; F and T can be accomplished with other movement techniques or a general search), which is good because we don't want to cause too much disruption when reassigning keys. We then have HJKL as remappable, and I've done the following:

//change FRST to up, left, down, right respectively
R --> H
S --> J
T --> L
F --> K

H --> S (s stands for substitute and in my mind is now hotSwap)
K --> R (r stands for replace and in my mind is now Kill)
J --> F (f goes before the next instance of a character, maybe it was Forward (?) but now I call it Jump)
L --> T (t goes To the next instance of a character which is similar to Forward. Now I call it Leap, which is similar to Jump but a leap is further)

The rest I keep the same, so you can still find most commands by pressing the letter that goes along with their mnemonic. As a bonus, H and K on Colemak are still next to each other as are J and L, so it makes a lot of sense physically.

In general though, using FRST simply avoids worse problems when trying to find 4 keys that are next to each other to take the place of arrows. If you did a direct HJKL to HNEI on Colemak then you lose Next and Insert which are quite notable to lose.
« Last Edit: Tue, 09 April 2013, 23:31:26 by oneproduct »
Layout: Colemak
Fastest typing speed: 131 WPM on typeracer, 136 WPM on 10fastfingers.
Daily driver: Filco Tenkeyless MX Brown with ergonomically weighted, lubed springs.
Ergo keyboards: Truly Ergonomic, Kinesis Advantage, Ergodox

Offline wolfv

  • Thread Starter
  • Posts: 269
Re: Vim on non-QWERTY layout?
« Reply #2 on: Wed, 10 April 2013, 00:37:10 »
Thank you oneproduct.  Your remapping strategy makes sense.

Offline SimpleRabbit

  • Posts: 2
Re: Vim on non-QWERTY layout?
« Reply #3 on: Wed, 10 April 2013, 00:49:43 »
Hallo, I'm another Colemak user. I've been using it for around 4-5 years alongside Vim and highly recommend it with or without Vim! I actually have a better experience with Vim in Colemak than I did in Qwerty.

My mappings are fairly simple...keep the homerow keys "hjkl" -> "hnei"...that means k, j, and l are now free and n, e, and i need to be accounted for.
  • "s/S" instead of "i/I" is now "inSert" or "Start" was my mnemonic.
  • "k/K" [same location as Qwerty "n/N"] replaces "n".
  • "l/L" is now free, and I use it for BOL/EOL [i.e. ^ and $ which were impossible for me to remember and conveniently use before switching].
  • "j" and "e" were rarely used by me, and the difference between the two doesn't warrant an entire new key, so I just use "j/J" now to map to "e/E".
  • Since "J" is taken, I use ctrl+L to join lines. "L" becomes the BOL/EOL/join line button, which feels more natural and convenient to me than ^, $, and J.
  • And I use "r" to mean "inneR text object" since "i" is a directional key now, like you'd use diw to "delete inner word".
Here're my Colemak key mappings I've been very happy using for 4+ years:
Code: [Select]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colemak Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" hnei = arrows
  noremap n gj|noremap e gk|noremap i l|noremap gn j|noremap ge k
" s/S = inSert
  noremap s i|noremap S I
" k/K = last search
  noremap k n|noremap K N
" l/L = BOL / EOL | <c-l> = join lines
  noremap l ^|noremap L $|noremap <C-l> J
" j/J = end of word
  noremap j e|noremap J E
" _r_ = inneR text objects
  onoremap r i
" c-e/c-n/c-m or <cr> = High/Low/Mid
  noremap <c-e> H|noremap <c-n> L|noremap <c-m> M
" shift+direction switches split panes
  noremap H <C-W>h|noremap I <C-W>l|noremap N <C-W>j|noremap E <C-W>k
" c-h/c-i switches tabs [inoremap <c-i> messes up insert-mode tabbing]
  nnoremap <c-i> <C-PageDown>|nnoremap <c-h> <C-PageUp>
" U = Redo with U
  noremap U <C-r>

" Not Colemak specific, but I like it :)
  noremap ; :

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  let g:NERDTreeMapJumpFirstChild      = "ge"
  let g:NERDTreeMapJumpLastChild       = "gn"
  let g:NERDTreeMapToggleHidden        = "H"
  let g:NERDTreeMapOpenSplit           = "S"

The only inconvenience I've experienced was a plugin [forget which] that hard coded "map"s into it, so I had to crawl through their source to fix them, but wound up not using the plugin anyways. Surround.vim, NERDTree, and others all have worked nicely for me.
« Last Edit: Wed, 10 April 2013, 01:14:45 by SimpleRabbit »

Offline SimpleRabbit

  • Posts: 2
Re: Vim on non-QWERTY layout?
« Reply #4 on: Wed, 10 April 2013, 01:15:30 »
Related, here are my Colemak .lessrc and .pentadactylrc [vimperatorrc] if you use them as well.

Full ~/.lessrc
Code: [Select]
#command
n forw-line
e back-line

N forw-line-force
E back-line-force

d forw-scroll
u back-scroll

f forw-screen
b back-screen

/ forw-search
? back-search
k repeat-search
K reverse-search

g goto-line
G goto-end
% percent

Snippet for ~/.pentadactylrc
Code: [Select]
" Standard Vim 'Homerow' Arrows
map -builtin n <Down>
map -builtin N 20<Down>
map -builtin e <Up>
map -builtin E 20<Up>
map -builtin i l
map -builtin I L

" k/K = repeat/reverse last search
map -builtin k n
map -builtin K N

" switch command line mode / extended hint mode
map -builtin ; :
map -builtin : ;

" select next/previous tab
map -builtin <c-i>   gt
map -builtin <c-h>   gT
imap -builtin <c-i>  <esc>gt
imap -builtin <c-h>  <esc>gT

" move current tab left/right
map -builtin <c-s-I>   :tabmove! +1<CR>
map -builtin <c-s-H>   :tabmove! -1<CR>
« Last Edit: Wed, 10 April 2013, 01:17:45 by SimpleRabbit »

Offline pyro

  • Posts: 177
Re: Vim on non-QWERTY layout?
« Reply #5 on: Thu, 11 April 2013, 13:24:10 »
I use Dvorak and Vim. Haven't changed anything, because its just fine like that.

Offline eviltobz

  • Posts: 95
Re: Vim on non-QWERTY layout?
« Reply #6 on: Fri, 12 April 2013, 14:34:14 »
I switched to colemak a few months ago and I'm also something of a novice vim user (actually I mostly use vsvim as a vim emulation layer in visual studio, but it's the same sorta thing). I looked at the official colemak vim rebindings, but decided to stick to the normal setup to avoid confusing myself when reading vim tips etc and it's working ok for me. Were I less lazy might have tried making j & l be left and right and h & k be up and down to make a slightly more meaningful positioning, but, well, lazy.

One of the key drivers to my not changing anything is from seeing advice about people temporarily turning off hjkl in vim to force the use of other navigation techniques. As a novice vimmer that home row feels like a good draw, but there is so much to the range of motions that you can do it is good to try and ditch that char by char mentality for most things. Whilst I'm at it I'll pimp this ere book too: http://pragprog.com/book/dnvim/practical-vim for maximal vimmy goodness :)

Offline wolfv

  • Thread Starter
  • Posts: 269
Re: Vim on non-QWERTY layout?
« Reply #7 on: Fri, 12 April 2013, 15:23:12 »
eviltobz,

I haven't seen that Vim book before, it's new.  The reviewers at Amazon love it.

Turning off hjkl in vim is a great idea!  That experience will help me decide to remap keys or not, as well as force me to use more advanced vi navigation.

Thanks for all your inputs.  You have all been very helpful.

Offline sordna

  • Posts: 2248
Re: Vim on non-QWERTY layout?
« Reply #8 on: Sat, 13 April 2013, 14:48:13 »
I use Dvorak and Vim. Haven't changed anything, because its just fine like that.

I'm using Dvorak and doing exactly the same! Although I tend to use regular arrow keys more often than hjkl, since they are so easy to reach on the Kinesis Advantage.
Kinesis Contoured Advantage & Advantage2 LF with Cherry MX Red switches / Extra keys mod / O-ring dampening mod / Dvorak layout. ErgoDox with buzzer and LED mod.
Also: Kinesis Advantage Classic, Kinesis Advantage2, Data911 TG3, Fingerworks Touchstream LP, IBM SSK (Buckling spring), Goldtouch GTU-0077 keyboard