News for hackers. Stuff that matters.
Re:Vim – Minimal Setup Explained by markus_zhang on Thursday February 24, 2022 @10:46PM (#30463498)
Question for Vim users: how do you get used to hitting Esc very often? I know some switch Cap with Esc but still clunky.
Re:Vim – Minimal Setup Explained by ninepoints on Friday February 25, 2022 @12:47AM (#30464072)
Aside from the advice mentioned (I bind caps to escape), I find that beginners use escape waaaay more often than is necessary because they aren't using all the commands at their disposal. For example, entering insert mode to delete some characters instead of using d+motion or x. Or entering insert mode to add indentation instead of using the = operator. It would take too long to enumerate all the cases where there is a much more streamlined way to perform an operation than entering insert mode, but I think this would explain the difference in experiences between people that may have used longer and aren't bothered by escape-use frequency and newer vim users.
Re:Vim – Minimal Setup Explained by markus_zhang on Friday February 25, 2022 @08:26AM (#30466981)
Thanks. This is helpful. I never use those shortcuts and yes most of my Esc are for indentation and deletion.
Re:Vim – Minimal Setup Explained by shagmin on Friday February 25, 2022 @11:03AM (#30468691)
Indentation is a good example where insert mode isn't needed. Just do stuff like 5>>
Re:Vim – Minimal Setup Explained by Lio on Friday February 25, 2022 @04:31AM (#30465347)
First I “live” in command mode and only visit insert mode to …insert stuff afterwards which I always leave with escape.

So using vim becomes a series of small edits.

I map caps to Ctrl and use Ctrl-[ for escape.

That means I can still use Ctrl for insert mode shortcuts such as

  Ctrl-w (delete last word)
  Ctrl-r to insert a register  (eg Ctrl-r% for filename)
  Ctrl-h instead of reaching for backspace.
There’s loads of them.

It just takes a bit of muscle memory but if you’re a touch typist it’s well worth it IMHO.

Doing it this way, rather than say ‘jk’ in insert mode, also has the advantage of working in other vim-like programs where you’d have to repeat the mapping. If that’s even possible.

Re:Vim – Minimal Setup Explained by chrismorgan on Thursday February 24, 2022 @11:10PM (#30463638)
I’ve never found a problem with it. Right at the corner, it’s easy to hit with my left ring finger, sitting perfectly at a comfortable distance (based on where I rest my hands) for a slap in that general direction.

(I use my Caps Lock as Backspace. Backspace near the top right is vastly less comfortable to reach than Escape in the top left.)

Re:Vim – Minimal Setup Explained by avgcorrection on Friday February 25, 2022 @09:43AM (#30467775)
That’s how I use Escape too in Evil Emacs/Spacemacs. There is some funky default in Spacemacs where you can hit something like d+f in rapid succession in order to enter normal mode but I didn’t find it to be worth it.

People really like the home row but (1) I think it is fine to leave it once in a while and (2) my joints don’t like stay in a very static position for too long in any case.

Re:Vim – Minimal Setup Explained by afarviral on Friday February 25, 2022 @12:07AM (#30463899)
Disagree with Esc being in a good spot but having dabbled with the "workman" keyboard layout can confirm its quite lovely having backspace as caps. I often wonder about making capslock backspace, and original backspace becoming Escape. Since I already have strong muscle memory to stretch to backspace...
Re:Vim – Minimal Setup Explained by johncoltrane on Friday February 25, 2022 @02:40AM (#30464613)
We simply do get used to that and all the rest. The benefits of modal editing far outweigh the eventual clunkiness of pressing a given key now and then. But the more you know how to use Vim, the less you need to get in and out of insert mode and the less you need to hit <Esc>.
Re:Vim – Minimal Setup Explained by assbuttbuttass on Friday February 25, 2022 @12:20AM (#30463972)
I actually use Ctrl+[ instead of escape. It takes some getting used to but it's easy to reach
Re:Vim – Minimal Setup Explained by krat0sprakhar on Thursday February 24, 2022 @10:58PM (#30463563)
I use `jk` or `jj` instead of esc. Its so much easier

   imap jj <ESC>
Re:Vim – Minimal Setup Explained by rbonvall on Friday February 25, 2022 @11:00AM (#30468653)
I've been using this mapping for so long and it's so ingrained in my brain that I completely forgot about it. It used to happened that I'd start typing jjjjj into a textarea or a word processor, and it took me a while to realize what was wrong.
Re:Vim – Minimal Setup Explained by soraminazuki on Friday February 25, 2022 @02:27AM (#30464552)
Doom Emacs had this behavior by default, and it caught me by surprise when it prevented me from typing "noto-fonts-cjk." I knew a lot of people do this in Vim, but it took some time to figure out exactly what had happened. Excellent framework though.
Re:Vim – Minimal Setup Explained by alexwennerberg on Friday February 25, 2022 @12:52AM (#30464088)
I tried this, but it (understandably) caused a delay whenever I typed j alone in insert mode
Re:Vim – Minimal Setup Explained by xigoi on Friday February 25, 2022 @05:24AM (#30465697)
You can map both jk and kj to Esc, which will allow you to press both of them simultaneously. Then you can set your timeout quite low when in insert mode.
Re:Vim – Minimal Setup Explained by csomar on Friday February 25, 2022 @05:19AM (#30465665)
It only matters if you are tying "jj". If you are typing "just", it's just as fast and the "delay" is just visual.
Re:Vim – Minimal Setup Explained by jazzabeanie on Friday February 25, 2022 @01:42AM (#30464312)
Yeah, you get used to that.
Re:Vim – Minimal Setup Explained by afarviral on Friday February 25, 2022 @12:01AM (#30463878)
Its the weakest part of the vim keyboard scheme IMO for ergonomics, and switching modes in general. I wish there was an alternative that gave a nod to vim but remained in 'input' mode without loss of capability, you know...without having to be vscode. If the key layout wasnt even worse, and it wasn't a bloated mess (on windows at least) I'd have switched to Emacs. Capslock is mostly a redundant button so I wholey support remapping it and for me is the only sensible way to use vim, binding to jj is hacky and plays up often and is inefficienct, and ctrl+] is insanity for such a regular press. Caps as Esc is useful in games when remapped to esc too for speedy pausing or simply pressing it by accident to kill you in a gunfight lol struggles
Re:Vim – Minimal Setup Explained by usrbinbash on Friday February 25, 2022 @03:56AM (#30465106)
> I wish there was an alternative that gave a nod to vim but remained in 'input' mode without loss of capability

Problem is, without modes, we lose capability that comes from the fact that modes exist, such as simple characters being compositeable commands;

How should a non-modal editor know whether that [d] I just pressed is me wanting the letter `d` or the delete command? It can't;

Either I have to somehow tell it "the next letter I press is to be interpreted as a command", or "interpret what I press as commands until I say otherwise". The former gets tiresome rather quickly (what if I have to do several commands?), the latter would again be a modal editor.

Re:Vim – Minimal Setup Explained by Lio on Friday February 25, 2022 @04:45AM (#30465440)
Now I wouldn’t do this myself but…

If you want stay in insert mode most of the time you could use Ctrl-o to switch to command mode for a single command and then be immediately returned to insert mode.

Eg

  Ctrl-o de
To delete to the end of the current word.

Again, I definitely wouldn't do it that way but vim makes pretty much everything possible.

Re:Vim – Minimal Setup Explained by legogt on Thursday February 24, 2022 @11:07PM (#30463609)
Once I found out CTRL-[ did the same thing I haven't hit ESC since.
Re:Vim – Minimal Setup Explained by asicsp on Thursday February 24, 2022 @11:21PM (#30463683)
I wish Ctrl+[ wasn't tied to Esc. I hit that often instead of Ctrl+P. Haven't yet found a way to map Ctrl+[ to Ctrl+P without affecting behavior of Esc as well.
Re:Vim – Minimal Setup Explained by ckolkey on Friday February 25, 2022 @01:14AM (#30464181)
It's because your computer can't tell the difference. c-[ and ESC send the same key-code. Same with c-i and tab. What you can do to get around this is to remap one of them to something like f20 using Karabiner, then map f20 to what you like in vim.
Re:Vim – Minimal Setup Explained by asicsp on Friday February 25, 2022 @03:16AM (#30464830)
Thanks. Not sure if Karabiner is available for Linux, but I found https://stackoverflow.com/questions/41364833/karabiner-for-l... which might help me.
Re:Vim – Minimal Setup Explained by VTimofeenko on Sunday February 27, 2022 @01:09AM (#30485843)
Can recommend interception-tools mentioned in that SO link. I have been using them for quite a while, remapping caps to escape in desktop environment agnostic way.
Re:Vim – Minimal Setup Explained by airstrike on Thursday February 24, 2022 @11:36PM (#30463764)
Esc is probably the easiest key to hit in the keyboard? Tied with bottom left ctrl/fn and whatever you have in the other two corners. As in it's the easiest to misclick without accidentally hitting other keys
Re:Vim – Minimal Setup Explained by the_gipsy on Friday February 25, 2022 @02:20AM (#30464511)
The easiest are F and J, the home keys where your index fingers rest. The more you have to "reach away", the harder it is to always correctly reset your hand.
Re:Vim – Minimal Setup Explained by airstrike on Friday February 25, 2022 @09:55AM (#30467890)
well, we can’t really have F be a special key to return to normal mode
Re:Vim – Minimal Setup Explained by the_gipsy on Saturday February 26, 2022 @04:11AM (#30476255)
I'm not advocating for that! Just that Esc/Mode shouldn't be far. Vim uses Esc for mode switching because the author wrote vim on a keyboard that had Esc where now Capslock is on a modern keyboard.
Re:Vim – Minimal Setup Explained by that-whiny-boi on Friday February 25, 2022 @01:17AM (#30464198)
I use ctrl+c. Since I'm already used to ctrl+c while using a terminal, it became easy even in vim. By default vim goes to normal mode when you press ctrl+c
Re:Vim – Minimal Setup Explained by ZeroGravitas on Friday February 25, 2022 @04:16AM (#30465238)
I mentioned in another comment that I used to do this, note there are some rare cases when it's not the same as esc. You can remap Ctrl-c to be exactly the same though.
Re:Vim – Minimal Setup Explained by sundarurfriend on Friday February 25, 2022 @03:19AM (#30464851)
Caps Lock being Esc is so convenient that I use Esc a lot more outside of Vim too. Stop the browser loading a page? a quick pinky tap on the caps lock. Take the focus out of a text field (so I can use my Vimium commands)? tap the caps lock. Decide not to save or open that file after all? caps lock's got your back.

The remapping was originally for Vim, but now at least a third of my Esc usage is outside of it.

Re:Vim – Minimal Setup Explained by chestervonwinch on Friday February 25, 2022 @09:37AM (#30467714)
Agreed! But it's a frustrating experience when you find when a website or application doesn't implement Esc for what you find to be nearly standard behavior across other applications. E.g., it seems like 80% of lightboxes allow closing via Esc.
Re:Vim – Minimal Setup Explained by cturtle on Friday February 25, 2022 @12:31AM (#30464019)
Time. It slowly becomes second nature and now I quickly reach for esc in many applications, not just vim. It does seem weird at first, an insert key (i, a, o, etc) and an esc needed for every text addition, but over time you grow used to it.

I also have my caps mapped to both ctrl and esc. Ctrl when held, and esc when tapped. Wish I had done that ages ago.

Re:Vim – Minimal Setup Explained by ZeroGravitas on Friday February 25, 2022 @04:14AM (#30465218)
I remapped caps lock, to be control when you hold it and escape when you use it alone.

However, for a long time I used Ctrl-c instead of escape, which is 99% the same except in some odd corner cases (not recommending that, just mentioning my history).

These days I use the common vi tweak of 'jk' being mapped to escape.

Re:Vim – Minimal Setup Explained by kiwijamo on Thursday February 24, 2022 @10:50PM (#30463523)
I've just got used to over time. It's gotten to the point I accidently use vi keybindings in other applications. Luckily there's keybindings in common applications e.g. typing / followed by a search phrase works in Firefox as it does in Vi which is pretty cool.
Re:Vim – Minimal Setup Explained by tuxlifan on Friday February 25, 2022 @02:51AM (#30464689)
On my Ultimate Hacking Keyboard I have a mapping of (left)space+q to produce Esc which for this combo I hit comfortably with my left hand thumb + ring finger.

On other keyboards I find fishing for the Esc key with the left ring or sometimes even middle finger good enough since it's so prominently singled out on the top left corner on all the keyboards I had yet to use, but it breaks the flow a bit more.

It probably helps that I'm not typing in proper form for the 10-finger system but only some hodgepodge approximation of it...

Re:Vim – Minimal Setup Explained by edenlinger on Thursday February 24, 2022 @11:02PM (#30463583)
I use either karabiner on my laptop or map it in my keyboard firmware (mostly drive QMK boards for the last few years) to swap caps lock to escape on tap and control on hold. Makes vim life great. Also means that using ctrl+a as a tmux leader is comfortable to type.
Re:Vim – Minimal Setup Explained by apocolyps6 on Friday February 25, 2022 @12:24AM (#30463990)
Do you consider hitting enter/return for a newline to be clunky as well? Its generally the same size as caps lock and opposite it on the keyboard. I'd say I press return a bit more often then Esc when using vim, but its close
Re:Vim – Minimal Setup Explained by sbankowi on Friday February 25, 2022 @02:54PM (#30471596)
I type using my old Sun keyboard still. The escape key is where the tilde key is on normal US PC keyboards. So the pinky stretch is quite easy.

(Also the control key is where the caps lock is. Also another fine position.) :)

Re:Vim – Minimal Setup Explained by tharne on Friday February 25, 2022 @09:42AM (#30467768)
I use a programmable keyboard with thumb keys, similar to the ergodox. I have escape set to one of the thumb keys so that it's no more work than hitting "space".
Re:Vim – Minimal Setup Explained by ambrose2 on Thursday February 24, 2022 @10:56PM (#30463556)
Not a great answer, but I switched Cap with Esc and it took several months before I was hitting Esc automatically like you might Ctrl + s a document when stopping typing.
Re:Vim – Minimal Setup Explained by usrbinbash on Friday February 25, 2022 @03:49AM (#30465061)
Muscle memory. It feels clunky at first, especially when coming from a non-modal editor, but I hardly realize I am even doing it any more.
Re:Vim – Minimal Setup Explained by nabogh on Thursday February 24, 2022 @10:52PM (#30463531)
I've bound it to double J in my vim configuration file. First thing I do on every computer.
Re:Vim – Minimal Setup Explained by hsx on Friday February 25, 2022 @01:36AM (#30464284)
I don't. I use Ctrl-C instead.
Re:Vim – Minimal Setup Explained by wildrhythms on Friday February 25, 2022 @12:22AM (#30463982)
Rebind Caps Lock to Escape (or as a second escape). Can't live without it now.
Re:Vim – Minimal Setup Explained by fellellor on Friday February 25, 2022 @08:51PM (#30474601)
It’s pretty easy if you don’t think about it too much.
Re:Vim – Minimal Setup Explained by the_gipsy on Friday February 25, 2022 @02:21AM (#30464516)
Caps as Esc works like a charm outside of vim too!
Re:Vim – Minimal Setup Explained by dosethree on Thursday February 24, 2022 @10:56PM (#30463551)
how is using cap clunky? works great
Re:Vim – Minimal Setup Explained by rasengan0 on Saturday February 26, 2022 @03:22AM (#30476054)
Esc ? Never. Got so used to Alt-l
Re:Vim – Minimal Setup Explained by xaxaxb on Friday February 25, 2022 @06:36AM (#30466186)
Ctrl + [