Showing posts with label Emacs. Show all posts
Showing posts with label Emacs. Show all posts

Friday, May 17, 2024

From (Programmers) Dvorak to (Neo) 3L

Dvorak mode: My journey learning the ThreeLayout (3L). I've decided to document my journey and capture my thoughts in a diary / journal format while going through the process. 

Why?: I enjoyed using Programmers Dvorak for the past 6 years, especially during software development sessions. However I had a few initial cons, which are the usual Vi(m) layout, and then later Emacs. Vim wasn't so bad, but when I started getting into Common Lisp, I switched back to Emacs, with Vanilla layout. As any Dvorak user can attest to, that required some finger gymnastics and became a pain after awhile. Swapping Alt with Ctrl eased that pain somewhat, and Lispy was a boon. I remembered using Xah Lee's Emacs keybindings in 2011 when I was getting into Emacs, so I decided to pick it back up, and most Emacs issues dissappeared afterwards. 

Then another issue arose, I realised that after getting in the zone (flow state) and coding for two to three hours, both pinkies were sore. While Programmer's Dvorak made reaching symbols easier, there were times when numbers needed to be interspersed during typing, sometimes a lot. I've been ignoring it for the most part for the past couple years, and it never developed into anything. Yet, it kept annoying me. Of course, an ergo keyboard would solve that issue, if I could afford it. Unfortunately, I am not in that position.

I started researching, and began seeing Colemak DH being touted as a great alternative. The thing is, I was spoilt by the ease of reaching the symbols with my strongest fingers, and Colemak DH seem to stick closely to QWERTY's symbol layout. I was on the verge of trying it out, but I also kept seeing other alternatives pop up once in a while, Neo / CarpalX / etc. The more I looked into Neo or Bone, the appeal was there, especially since it catered to programming. As I was about to give Bone a try, I saw their alternative layout section with a mention of an English focused layout, 3L. That sealed the deal for me, and the rest of this post is the result of that. 

As part of the learning process, I am going cold turkey, just as I did for Dvorak. I switched my Windows and FreeBSD bindings. The following is written solely with 3L.

3L mode: 

May 15th, 2024

First post typed using Three Layout, while learning, to capture my thoughts and document my progress.
  • Dvorak 1 year, Progrommers Dvorok 6 years
  • Started 3L cold turkey May 15, 2024
  • Switched Windows (ReNeo) and FreeBSD (setxkbmap us 3L) layouts
  • Using ReNeos onscreen keyboard
  • Trained on Klavaro up to level 20. Home and top rows. 

May 16th, 2024

  • I am left handed, and found it interesting that I spent more time training the left keys with more focus. Would default to Dvorak while training, but making a mistake would "reset" my fingers.
  • The right home keys flowed almost unconsciously. After checking, home row has similarities with Dvorak. e, t, n, s
  • Still confusing O with A...o lat.
  • Wrote company emails. Slow, not painful
  • Retrain up to level 20 in Klavaro. Home and top rows.

May 17th, 2024

  • Started from level 20, learning bottom rows, up to level 31
  • Turned off ReNeo on-screen keyboard and only reference for symbols. Chnfidence boosted.
  • After lvl 31, started velocity training. See results of first attempt, also compared with a quick switch over to Dvorak:

3L

Dvorak (tested immediately afterwards)

;; create a new layout
;; 3L with dead keys represented as _
(puthash "3l" "
_ 1 2 3 4 5 6 7 8 9 0 _ _
_ 1 2 3 4 5 6 7 8 9 0 _ _ 

q f u y z x k c w b _ _ \\
o h e a i d r t n s _
, m . j ; g l p v _

Q F U Y Z X K C W B _ _ _
O H E A I D R T N S _
, M . J ; G L P V _
" xah-fly-layout-diagrams)

May 18th, 2024 (After Shabbat)

  •  Just realized why typing feels strangely comfortable. Fingers are either straightened for top row or flexed for bottom row. Only index fingers are moved laterally and no over-extensions, all keys and symbols within reach.

May 19th, 2024

  • Fully committed on FreeBSD, setting my /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf to:
Section "InputClass"
        Identifier "Keyboard1"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbVariant" "3l"
        Option "XkbOptions" "ctrl:swap_lalt_ctl,ctl:swap_ralt_rctl,shift:both_capslock"
EndSection


May 24th, 2024

After some experimenting, decided to utilize Right-Alt as Cur key, similar to Neo based layouts and further reduce right pinky usage. Added benefit of having it act as a Cur 'lock'. Consulting man xkeyboard-config, resulted in the following XkbOptions

Option "XkbOptions" "ctrl:swap_lalt_ctl,shift:both_capslock,lv5:ralt_switch_lock"

Conclusion

WPM are steadily increasing and I am now comfortable enough using it on a daily basis, typing as low as 40 wpm. I only regress to Dvorak when I get in the flow state and start approaching 60 wpm and some of the bi-grams are still troublesome for me (ou, mo, ma, me) but I'm getting used to them.

This is definitely worth the effort of learning and the layers / levels are game changing



Friday, July 24, 2015

Vim: Rebind Caps Lock And Escape

In this article I discuss how I managed to bind Escape to my Caps Lock key and Caps Lock to Escape, not only for my OpenBox environment, but also for my Virtual Terminal/Console.

I recently decided to finally give Vi/Vim a try. Previously, I thought it was too arcane and tried Emacs instead. I was an avid Emacs user and it became my editor and IDE of choice. So why did I decide to switch?
My decision came down to three (3) things:
1. Why not?
2. Striving to be more productive (i.e. lazier...i.e. less keystrokes)
3. Vi is installed by default on Unix, so an advanced editor is always ready. So are ee, ed and a whole range of others, but I like the challenge and wanted to see what the rage was all about. Yes Emacs came with Mac OS X by default albeit an older version, so I still had to install the latest. On FreeBSD? pkg install emacs is your friend.
While using Emacs on OS X, I could easily remap the keybindings for Caps Lock to Control, in fact, it was a builtin feature of the OS. It's a bit more work to get it done on FreeBSD, so here goes.

OpenBox setup:

This was taken from the vim wikia:

  1. vi ~/.vimkeyswapper – you can name the file anything you want, I just wanted the easy reminder everytime I looked at it. This was easier to understand at a glance over '.xmodmaprc'.
  2. Edit the file to include the following contents:
    ! Swap CAPS LOCK and ESC
    remove Lock = Caps_Lock
    keysym Escape = Caps_Lock
    keysym Caps_Lock = Escape
    add Lock = Caps_Lock
  3. Edit either your ~/.config/openbox/autostart if you are using a login manager or your ~/.xinitrc if, like me you only need to start X when you really need to
    xmodmap ~/.vimkeyswapper
  4. Restart X, or reboot just to make sure it takes effect.

Console setup:

Alright, be careful here. We're going into the file system, which requires root privileges. Ironically, I found the original solution here.
  1. We need to decide which keyboard mapping we are using. So you'll need to install misc/kbdscan if you don't already have it installed.
    $ cd /usr/ports/misc/kbdscan && sudo make install clean
  2. Please note, you have to be in the console to be using this, so you can't be logged into X and use your terminals. So ALT+F1 or ALT+F(n) to whichever console you like and login.
    $ kbdscan
    Press and release Caps Lock and make a note of which number appears, for me it was 58
    Press and release Esc, the number I got was 1.
  3. Okay, you may have to do some digging around to find which files match the numbers you got.
    $ cd /usr/share/syscons/keymaps && ls
    Based on your locale, language or keyboard setup, it may be different for you. The file that matched my bindings were us.iso.kbd. [1]
    $ sudo cp us.iso.kbd us.vim.kbd
  4. Edit the file, so it should look something like this:
    # $FreeBSD: releng/10.1/share/syscons/keymaps/us.iso.kbd 74119 2001-03-11 23:41:19Z ache $
    # alt
    # scan cntrl alt alt cntrl lock
    # code base shift cntrl shift alt shift cntrl shift state
    # ------------------------------------------------------------------
    000 nop nop nop nop nop nop nop nop O
    001 clock clock clock clock clock clock debug clock O
    ...
    058 esc esc esc esc esc esc esc esc O
    … [2]


    I don't know if it made a difference or not, but I realigned the text before saving the file.
  5. Add this to your /etc/rc.conf file: keymap="us.vim.kbd"
  6. Reboot: # reboot OR $ shutdown -r now
  7. And there you have it, if done correctly, your Caps Lock will now be your new Esc key. Happy coding![3]
[1] – On a side note, they already have us.emacs.kbd, no fair to us vim users :-)
[2] – Ellipses denotes more content, I just did this to highlight the relevant changes. Please don't remove anything from this file.
[3] – I am not sure if this affects console only or the X environment as well, making the xmodmap command unneccessary.