TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Vim: Spacebar as leader key, CapsLock as Esc

39 pointsby normalocityover 11 years ago

20 comments

kpsover 11 years ago
<i>Perhaps I have spent so much time on Mac that pressing the Ctrl key for things feels unnatural vs. the Command key</i><p>Argh. OS X is the last significant platform that gets this right by not trying to use Control for menu shortcuts out of the box. When I&#x27;m in a terminal, or editor, or browser text box, it&#x27;s perfectly common and reasonable to want to distinguish Control-V (literal) from Command-V (paste), Control-Z (suspend) from Command-Z (undo), and so on.<p>Pre-Linux X Window software typically managed this, using Meta or some other keysym for GUI operations, but current ‘desktops’ seem dead set on imitating MS Windows. Damn kids get off my screen.
评论 #6917079 未加载
karmajunkieover 11 years ago
I basically do this, but I use &quot;,&quot; (comma) as my leader, and I make capslock do double duty as ctrl and esc using KeyRemap4MacBook (<a href="https://pqrs.org/macosx/keyremap4macbook/" rel="nofollow">https:&#x2F;&#x2F;pqrs.org&#x2F;macosx&#x2F;keyremap4macbook&#x2F;</a>). The trick is first remap capslock to Ctrl in keyboard system preferences, then use KR4MB to remap Control_L (the left control key, which is to say, what capslock now signals) to Control_L, but if you type ONLY Ctrl_L it sends esc. so when i need escape, it sends that. when i want to use it for Ctrl-modified combos, it does that. Works fantastically for Vim, i&#x27;ve been doing this for a couple years now. Also nice for emacs keyboard shortcuts in other apps that respond to them.
评论 #6917343 未加载
评论 #6917838 未加载
评论 #6917066 未加载
rc4algorithmover 11 years ago
To the many of you using Macbooks: be aware the that the caps lock key is deadened&#x2F;delayed in order to prevent mistaken pressing, and that this is a hardware feature that can&#x27;t be changed. This may be the case for Mac keyboards and other new systems as well.
q_revertover 11 years ago
I use &lt;space&gt; as my Easymotion leader..<p><a href="https://github.com/Lokaltog/vim-easymotion" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Lokaltog&#x2F;vim-easymotion</a><p>it&#x27;s well worth a look, gives you super quick fine grained movement<p>similarly<p><pre><code> inoremap jj &lt;ESC&gt; </code></pre> to take you from INSERT mode to NORMAL mode is nice
评论 #6916951 未加载
评论 #6917128 未加载
评论 #6916868 未加载
SmileyKeithover 11 years ago
I use CapsLock as escape but had I not gotten so used to that by now I would probably have used it for control instead and mapped escape to jk or something. I, like many people, use `,` for my &lt;leader&gt; and with Clever-F[0] I don&#x27;t lose the original functionality which is just remapped to consecutive presses of &#x27;f&#x27;.<p>[0]: <a href="https://github.com/rhysd/clever-f.vim" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rhysd&#x2F;clever-f.vim</a>
jfftover 11 years ago
Love spacebar as the leader key, but not a fan of CapsLock as Esc. CapsLock as Ctrl is better. For one, you never have to stretch for the real Ctrl, and two, you <i>can</i> use it for escape as well: Ctrl-[
评论 #6919161 未加载
评论 #6917045 未加载
评论 #6917249 未加载
jdonaldsonover 11 years ago
I broke things down by priority. I notice that I jump around in documents by searching through them, rather than by navigation keys. Spacebar is the biggest key on the keyboard, so, spacebar is mapped to &quot;?&quot; in normal mode. I also find that I need to search through a project regularly, so ctrl-spacebar is mapped to the ack&#x2F;ag command.<p>Control is mapped to caps lock at the os level for me. There are also too many useful commands in vim that use control (visual block mode is huge). I tried mapping jj to escape as well, but ctrl-c is just as easy.<p>Leader is mapped to comma. Most of my leader commands are comma + &quot;some letter I can type with my left hand&quot;.
评论 #6918106 未加载
glynchover 11 years ago
I prefer remapping capslock to control for easier use of commands like &lt;C-f&gt;, &lt;C-b&gt;, &lt;C-e&gt;, &lt;C-h&gt;, and &lt;C-l&gt; (all of which were absent in the example vimrc posted). Using the leader key makes total sense for dealing with splits and buffers or plugins you might want to look into some of the other Control based commands that Vim supports.
评论 #6917344 未加载
mungerover 11 years ago
Thanks for the easy-to-understand take on the leader key. Not using the leader key is one of my known vim weaknesses I&#x27;ve been meaning to fix. I found your explanation and usage a great push into actually putting it in my .vimrc
CGamesPlayover 11 years ago
I end up using Ctrl for a bunch in vim: visual block, ctrlp (and &lt;C-b&gt; for buffer mode), window nav, and most importantly, imported emacs keybindings. The emacs line motion commands (specifically &lt;C-a&gt;, &lt;C-e&gt;, and &lt;C-d&gt;) are extremely useful because they work in every app on my mac, so not having to lose flow when I&#x27;m in vim or a browser is nice.<p><a href="https://github.com/CGamesPlay/dotfiles/blob/master/files/vimrc#L152" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CGamesPlay&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;files&#x2F;vim...</a>
Theodoresover 11 years ago
If I am going to have to relearn where some of the keys are in vim then I might as well go the whole hog and get a Dvorak keyboard whilst I am at it!
评论 #6916852 未加载
sethishover 11 years ago
I&#x27;ve been using this since [~2010](<a href="https://github.com/sethwoodworth/dotfiles/commit/801f4a7163db017c0be7edaee2e358b7f3d4bf50#diff-4e12c6a37ff2cbb2c93d1b33324a6051R77" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sethwoodworth&#x2F;dotfiles&#x2F;commit&#x2F;801f4a7163d...</a>). I highly recommend leader as space.
svermeulenover 11 years ago
Why not map caps lock key to both escape AND control? I&#x27;ve been doing this successfully for a long time and couldn&#x27;t live without it. You can use Autohotkey on windows and similar tools on other systems to interpret caps lock pressed by itself as escape, and caps lock pressed + another key as control.
97-109-107over 11 years ago
The is a way of minimizing the frequency of having to reach esc (be it at esc or caps lock) &quot; jj For Quicker Escaping between normal and editing mode. inoremap jj &lt;ESC&gt;
jagger27over 11 years ago
What is a leader key? How much typing class did I miss?!
评论 #6916543 未加载
评论 #6916548 未加载
评论 #6916547 未加载
etanazirover 11 years ago
I use &#x27;,&#x27; and my leader; but have been considering remapping &#x27;esc&#x27; ... any suggestions other than CapsLock?
评论 #6917332 未加载
ryan-thompsonover 11 years ago
I love this idea, I never thought of using the spacebar as anything other than a space.
erikbover 11 years ago
Nobody said it yet, so I have to do it: Happy Hacking Keyboard
harryoversover 11 years ago
i have capslock as my backspace key. where do i put escape now?
knodiover 11 years ago
i use my caps as control key.