News for hackers. Stuff that matters.
Re:Vim Anywhere by amelius on Friday February 16, 2018 @04:29PM (#16396541)
Meanwhile, the Escape key on popular keyboards is getting smaller and smaller :(
Re:Vim Anywhere by dag11 on Friday February 16, 2018 @04:55PM (#16396812)
Fun fact, Ctrl+[ also escapes. Had to retrain my muscle memory to use Ctrl+[ when I got my Touch Bar mac, but I think I actually prefer it to ESC. It's guaranteed to work on vim on any system (unlike caps lock), and it keeps my fingers closer to home row.
Re:Vim Anywhere by spraak on Friday February 16, 2018 @08:36PM (#16398306)
Hm... I was able to 'feel' the ESC key on my touch bar. But I then remapped it to Caps Lock using Karabiner. I also remapped it on my Ubuntu laptop (with Xmodmap) since it's so nice. What systems have you not been able to get it to work on?
Re:Vim Anywhere by _betty_ on Sunday February 18, 2018 @02:32AM (#16404925)
Other people's (when pair programming)
Re:Vim Anywhere by K0nserv on Friday February 16, 2018 @06:35PM (#16397598)
The best line in my whole vimrc is this https://github.com/k0nserv/dotfiles/blob/master/files/vimrc..... It rebinds jk to ESC. This has the nice property of being a NOP if you happen do do it in normal mode
Re:Vim Anywhere by spraak on Friday February 16, 2018 @08:19PM (#16398231)
But what would it do in visual mode?
Re:Vim Anywhere by Pete_D on Saturday February 17, 2018 @08:30AM (#16400572)
Nothing, but you could add a `vnoremap jk <Esc>` line as well to have it leave visual mode if you wanted.
Re:Vim Anywhere by K0nserv on Saturday February 17, 2018 @09:02AM (#16400696)
I stil use ESC for visual mode, but as @Pete_D points out you could use jk there too, however it's a much more common input in visual mode so it would probably not work as well.
Re:Vim Anywhere by platinumrad on Friday February 16, 2018 @04:32PM (#16396574)
You can rebind caps lock to escape.
Re:Vim Anywhere by tetraodonpuffer on Friday February 16, 2018 @04:36PM (#16396622)
or rebind it to ctrl if held, escape if tapped, making it even better for RSI purposes
Re:Vim Anywhere by Scarbutt on Friday February 16, 2018 @05:59PM (#16397335)
and enter to ctrl if held and enter if tapped ;) (macbooks don't have a right ctrl key).
Re:Vim Anywhere by Lio on Saturday February 17, 2018 @05:30AM (#16400058)
Personally I prefer to use Karabiner-Elements to remap the right alt-key to ctrl. Been doing that since the first MacBook Pro when the key in that position was “Enter”.

I find I don’t really miss the right alt key at all.

Re:Vim Anywhere by zcid on Friday February 16, 2018 @06:09PM (#16397407)
And what a nightmare it is to jump on a macbook because of that. I go crazy when I need to use an Apple keyboard. I can't begin to understand that particular ui choice.
Re:Vim Anywhere by mkl on Friday February 16, 2018 @04:46PM (#16396707)
What do you use to do this? On what operating systems?
Re:Vim Anywhere by tetraodonpuffer on Friday February 16, 2018 @05:51PM (#16397268)
as the two other sibling posters said, I use karabiner elements when on os/x and xcape+xmodmap on Linux with this in my .xsession

  xcape -e 'Control_L=Escape'
which is run after remapping caps lock to Control_L via xmodmap (just xmodmap -pke to create your xmodmap file, xev to figure out which keycode your caps is, and edit the file after to make that keycode Control_L.

For example my xmodmap file, which also sets up meta/super and other overrides is

  !
  ! Clear the modifiers
  !
  clear    lock
  clear    shift
  clear    control
  clear    mod1
  clear    mod2
  clear    mod3
  clear    mod4
  clear    mod5
  
  ! Remapping
  keycode  37 = F17 NoSymbol F17
  keycode  64 = Alt_L NoSymbol Alt_L
  keycode  66 = Control_L NoSymbol Control_L
  keycode  90 = Multi_key NoSymbol Multi_key
  keycode  91 = Mode_switch NoSymbol Mode_switch
  keycode 105 = Meta_R NoSymbol Meta_R
  keycode 107 = Menu Sys_Req Menu Sys_Req
  keycode 108 = Control_R NoSymbol Control_R
  keycode 127 = Redo Undo Redo Undo
  keycode 134 = Alt_R NoSymbol Alt_R
  keycode 135 = Control_R NoSymbol Control_R
  keycode 164 = Undo Redo Undo
  keycode 166 = Super_L NoSymbol Super_L
  keycode 167 = Control_L NoSymbol Control_L
  
  !
  ! Set the modifiers
  !
  add shift   = Shift_L Shift_R
  add control = Control_L Control_R
  add mod1    = Alt_L Alt_R
  add mod2    = Num_Lock
  add mod3    = Super_L
  add mod4    = Meta_R
  add mod5    = Mode_switch
Re:Vim Anywhere by alienreborn on Friday February 16, 2018 @05:26PM (#16397049)
I use this app on Mac for the exact key mentioned above Caps -> Ctrl/Esc

https://github.com/tekezo/Karabiner-Elements

Re:Vim Anywhere by farresito on Friday February 16, 2018 @04:49PM (#16396747)
If you are on Linux, try xcape; on Windows, you can do it with autohotkey.
Re:Vim Anywhere by fencepost on Saturday February 17, 2018 @03:27PM (#16402529)
Remapping CapsLock to Ctrl on Windows is easy with KeyTweak (what I have is 2.3.0 by Travis Krumsick), though I had to select the CapsLock key from the displayed keyboard rather than simply hitting the key. All it appears to be doing is updating the Registry's key mapping values based on the keyboard scan codes. Easily found with a simple search, and it does work on Windows 10 even though it hasn't been updated for 8+ years.

I suspect you'd have to switch to something like Autohotkey for the Esc/Ctrl mapping.

Re:Vim Anywhere by amelius on Friday February 16, 2018 @04:37PM (#16396630)
That's a good one!
Re:Vim Anywhere by aidos on Friday February 16, 2018 @05:44PM (#16397214)
Oh that’s interesting!
Re:Vim Anywhere by amelius on Friday February 16, 2018 @04:37PM (#16396625)
I already bound it to Ctrl.
Re:Vim Anywhere by chongli on Friday February 16, 2018 @05:00PM (#16396864)
I bound caps lock to ctrl. I use it with ctrl-[ to escape in vim. Does everything I need.
Re:Vim Anywhere by platinumrad on Friday February 16, 2018 @04:46PM (#16396711)
I've heard of some people rebinding Ctrl to Esc after doing that.

Or there's always dual binding Caps Lock (tapped vs held) as tetraodonpuffer suggested but I've never been able to get used to that.

Re:Vim Anywhere by derriz on Friday February 16, 2018 @04:59PM (#16396852)
I've gotten used to typing CTRL-[ instead of reaching for the Escape key because of the inconsistencies in its size and placement on various keyboards I use. Yes it's two fingers but you have to use CTRL in vim to get any benefit anyway.
Re:Vim Anywhere by Moter8 on Friday February 16, 2018 @05:23PM (#16397022)
Quite difficult to type CTRL-[ for me, as it's actually CTRL+ALT+8 on a german layout keyboard :/

Oh, and on Mac CTRL+ALT+5 if I remember correctly.

Re:Vim Anywhere by fphilipe on Saturday February 17, 2018 @02:25AM (#16399530)
Have been using a US keyboard and never looked back to the Swiss one. Much better for programming and accents and umlauts are still easy to type. As I also occasionally type in Portuguese, German, Spanish, and French, I find the US keyboard to be the neutral middle ground.
Re:Vim Anywhere by oelmekki on Saturday February 17, 2018 @02:10PM (#16402160)
On linux, I don't use ESC at all anymore, I just press alt + [a normal mode key], while in insert mode. Like `alt + j`, which will leave insert mode and move one line down.

Some alt based sequences are really useful:

* alt + e, a : leave current parenthesis and continue inserting (eg, while typing parameters for a function)

* alt + shift + a : insert mode at the end of current line

* alt + shift + i : insert mode at the beginning of current line, with indentation

* alt + p, a : paste before current position, and continue inserting

Maybe there's a modifier key with a similar behavior on macosx?

Re:Vim Anywhere by vram22 on Tuesday February 20, 2018 @12:45PM (#16422222)
>On linux, I don't use ESC at all anymore, I just press alt + [a normal mode key], while in insert mode. Like `alt + j`, which will leave insert mode and move one line down.

Why does that work? Is it because Alt + some_key combos generate an escape sequence starting with the actual ESC character? I know that happens with many function key combos, don't remember or not sure about Alt combos.

Re:Vim Anywhere by oelmekki on Tuesday February 20, 2018 @01:42PM (#16422741)
This sounds plausible, but I have really no idea of why it works :) I found it by doing a mistype (like it often happens in vim), and didn't see it mentioned in any article that would try to get to the bottom of it yet.
Re:Vim Anywhere by vram22 on Tuesday February 20, 2018 @02:38PM (#16423417)
>I found it by doing a mistype (like it often happens in vim)

Ha, I probably found it by some similar way, maybe in vim or maybe in DOS / Windows / Linux at the command prompt or in some curses or terminal application.

Re:Vim Anywhere by vram22 on Tuesday February 20, 2018 @12:44PM (#16422206)
>* alt + shift + a : insert mode at the end of current line

Is that different from just Shift-a or capital A, which puts you into append mode at the end of the current line (no matter where you are on the line when you press it)?

Re:Vim Anywhere by oelmekki on Tuesday February 20, 2018 @01:39PM (#16422718)
yep, it does a 'A' in normal mode, after leaving the insert mode (thanks to alt). The different thing is that you do it (alt+shift+a) in insert mode. So the equivalent would be `ESC, A`.
Re:Vim Anywhere by vram22 on Tuesday February 20, 2018 @02:41PM (#16423449)
Then I guess that the Alt key generates an ESC char (ASCII code 27 [1]). Seems to tie in with the fact that Emacs docs say that you can use either Alt or ESC for the Meta key - which is used a lot in Emacs commands (IIRC - I am not an Emacs user, just had tried it out earlier and think I remember reading read that).

https://en.wikipedia.org/wiki/Esc_key

Re:Vim Anywhere by oelmekki on Wednesday February 21, 2018 @05:39AM (#16428468)
I see. thanks for sharing!
Re:Vim Anywhere by eddyg on Saturday February 17, 2018 @06:32AM (#16400254)
Just use Ctrl-C instead of Escape. Often less hand-motion than going all the way to the upper-left, and it works everywhere, without custom remapping of Caps Lock, etc.
Re:Vim Anywhere by cestith on Friday February 16, 2018 @08:22PM (#16398244)
Here's one way to mitigate that: use a less popular keyboard. I suggest evaluating https://shop.keyboard.io/ for starters.
Re:Vim Anywhere by Lio on Saturday February 17, 2018 @05:37AM (#16400082)
I love the idea of a mechanical keyboard but I worry about productivity when I’m on the move.

I find it easier to stick to the laptop keyboard and trackpad even when at a desk plugged into a big monitor.

Everytime I try to switch to a mechanical keyboard and mouse my wrists start hurting. I guess this would go if I got used to the position but then what would happen when I have to use the laptop keyboard?

(So far I’ve tried an IBM model-m and a Pok3r keyboard).

Re:Vim Anywhere by imahorse on Saturday February 17, 2018 @07:30PM (#16403684)
From my experience, my wrists start hurting if I don't use any wrist rests (despite the name, you're supposed to rest your palms on them) Also, tilted or high profile keyboards are less ergonomic IMHO.

Don't worry about switching back to the laptop keyboard on the go. You won't be less productive, you will just enjoy it less :)

Re:Vim Anywhere by vram22 on Tuesday February 20, 2018 @12:41PM (#16422181)
On some laptops too :(