News for hackers. Stuff that matters.
Re:Modeless Vim by joenot443 on Tuesday January 16, 2024 @08:59AM (#39013316)
> Remap the Escape key to CapsLock else you will never like vim (provided you are a normal person)

I think this is great advice for EVERYONE, vim user or not. Someone else made this suggestion on HN some 8 years ago and I haven't looked back since.

CapsLock is essentially useless for modern computing needs, but having a No/Cancel/Quit/Esc button immediately under your left pinky is fantastic. Your brain will get used to it in a day or so, give it a try!

Re:Modeless Vim by joshmanders on Tuesday January 16, 2024 @12:12PM (#39015780)
If I remap CapsLock to Escape, then how will I enable cruise control for awesome mode?

But seriously, I have hitting escape muscle memory engrained, I cannot remap it to any key because I won't ever think to hit capslock even if it's ergonomically "better"

Re:Modeless Vim by TotempaaltJ on Tuesday January 16, 2024 @12:26PM (#39015976)
I thought that, remapped it, and it turned out to be incredibly easy to swap over. I think it's because it's so much nicer to use.
Re:Modeless Vim by joshmanders on Tuesday January 16, 2024 @12:46PM (#39016240)
My point is that it's NOT nicer to use for me.

I just instinctively did it to see my motion and it's an awkward feeling for me to move my left pinky over to the capslock key, definitely something I have to be mindful of doing to make happen and probably will take a long time for me to get used to.

Meanwhile, I actually extend my ring finger up and barely touch the escape and move it back down, all of that is very comfortable for me and I can do it without looking 100% of the time and never miss it.

Re:Modeless Vim by zeroxfe on Tuesday January 16, 2024 @09:13AM (#39013435)
Yes, CapsLock is useless, and I've been remapping it to Ctrl since forever, which serves me a lot more than Esc.
Re:Modeless Vim by cassepipe on Tuesday January 16, 2024 @10:58AM (#39014806)
It can be both if you care to. You don't have to choose
Re:Modeless Vim by Toorkit on Tuesday January 16, 2024 @01:48PM (#39017103)
I've done Esc-on-single-press-Ctrl-on-hold once, but some games don't recognize the Esc press. Couldn't get to a menu anymore :P

Currently just have Esc on the CapsLock.

Re:Modeless Vim by sodapopcan on Tuesday January 16, 2024 @09:24AM (#39013530)
Best use for capslock in my book is tap for escape, hold for ctrl.
Re:Modeless Vim by ta988 on Tuesday January 16, 2024 @10:55AM (#39014759)
Where do you map it that way?
Re:Modeless Vim by sodapopcan on Tuesday January 16, 2024 @11:27AM (#39015151)
As my sibling commenter said, use Karabiner Elements if you are on macos. Though it's not an out-of-the-box thing.

Add this config to ~/.config/karabiner/assets/complex_modifications/custom-capslock.json

    {
      "title": "Change caps_lock to Esc and Control",
      "rules": [
        {
          "description": "Post Esc if Caps is tapped, Control if held.",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "left_control",
                "modifiers": {
                  "optional": [
                    "any"
                  ]
                }
              },
              "to": [
                {
                  "key_code": "left_control",
                  "lazy": true
                }
              ],
              "to_if_alone": [
                {
                  "key_code": "escape"
                }
              ]
            }
          ]
        }
      ]
    }
and then in the GUI enable it in the Complex Modifications tab. Last you need to map "capslock" to "left_control" in the Simple Modifications tab.
Re:Modeless Vim by linsomniac on Tuesday January 16, 2024 @12:56PM (#39016372)
Ooh! Can I do this with "z" and "/" (letter if tapped, control if held)?
Re:Modeless Vim by sodapopcan on Tuesday January 16, 2024 @01:09PM (#39016514)
My GUESS is that it would be something like this:

    {
      "title": "Hold z or / for control",
      "rules": [
        {
          "description": "Hold z for control",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "z",
                "modifiers": {
                  "optional": [
                    "any"
                  ]
                }
              },
              "to_if_alone": [
                {
                  "key_code": "left_control"
                }
              ]
            }
          ]
        },
        {
          "description": "Hold / for control",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "/",
                "modifiers": {
                  "optional": [
                    "any"
                  ]
                }
              },
              "to_if_alone": [
                {
                  "key_code": "right_control"
                }
              ]
            }
          ]
        }
      ]
    }
Re:Modeless Vim by sodapopcan on Tuesday January 16, 2024 @01:06PM (#39016486)
Yep! You can do whatever you want with complex modifications. The only tricky part is figuring it out. It shouldn't be TOO different than the above if you replace the appropriate values.
Re:Modeless Vim by ink_13 on Tuesday January 16, 2024 @11:16AM (#39015047)
Karabiner-Elements will do this for you on Mac.

I consider it indispensable.

Re:Modeless Vim by wonger_ on Tuesday January 16, 2024 @01:58PM (#39017285)
I use this executable for Windows: https://github.com/ililim/dual-key-remap
Re:Modeless Vim by svilen_dobrev on Tuesday January 16, 2024 @02:30PM (#39017841)
as said here: https://superuser.com/questions/1716264/xmodmap-holding-a-ke... using this https://github.com/alols/xcape :

  $ setxkbmap -option caps:ctrl_modifier
  $ xcape  -e 'Caps_Lock=Escape'
if that need be run multiple times (i.e. in bashrc), add a guard:

  pgrep xcape >/dev/null || (
   setxkbmap -option caps:ctrl_modifier
   xcape  -e 'Caps_Lock=Escape'
  )
Re:Modeless Vim by joenot443 on Tuesday January 16, 2024 @02:15PM (#39017598)
That sounds awesome! I'm going to look into that.