TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

If you have failed to grok vim, ditch the arrow keys

20 点作者 bw2大约 12 年前

10 条评论

ominous_prime大约 12 年前
I always liked the way this answer was presented as vim via vi.<p>&#62; Your problem with Vim is that you don't grok vi.<p><a href="http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118" rel="nofollow">http://stackoverflow.com/questions/1218390/what-is-your-most...</a>
kps大约 12 年前
If you have failed to grok vi[m], you need two things. First, to understand just a little of two other editors, ed and TECO. Second, to know that vi's <i>real</i> modes are not what the naïve user, and sadly most documentation, call ‘modes’; they are line mode (ed mode) and visual mode (TECO mode).<p>ed is a line editor based on search-and-replace using regular expressions. To edit existing text, you typically locate it with a search and change it with a replace. Sometimes you refer to nearby lines with .±n addressing, and sometimes by absolute line number (having printed a few lines with the ‘n’ command); and sometimes you change entire lines (with ‘c') rather than doing a replacement; but really, search-and-replace is where it's at. vi's line mode, which you enter with ‘Q’ or more commonly one-off with ‘:', is just ed on steroids.<p>TECO is a character stream oriented editor, or, if you prefer, a programming language for manipulating streams of text. <a href="http://scientopia.org/blogs/goodmath/2010/11/30/the-glorious-horror-of-teco/" rel="nofollow">http://scientopia.org/blogs/goodmath/2010/11/30/the-glorious...</a> is a decent short introduction. TECO text manipulation functions have an optional count, a function name (one or two characters), and an optional argument terminated by ESC. That should already look familiar; vi's visual mode is watered-down TECO. Sure, many of the functions have different names — vim's ‘h’ and ‘l’ are TECO's ‘r’ and ‘c’ — but some are the same: ‘i’ followed by an argument (i.e. some text) terminated by ESC is the function that inserts its argument before the current editing point. It's counterproductive to think of vi as having an ‘insert mode’ and ‘append mode’ and ‘replace mode’ and ‘substitute mode’ and whatnot, just as it would be conterproductive to think of the <i>x</i> in <i>sin(x)² + cos(x)²</i> as being in ‘sine mode’ or ‘cosine mode’.<p>Spend an hour with ed and an hour with TECO, and you'll begin to grok vi.
cdash大约 12 年前
Why not just use jikl instead if you don't want to lift your hand to move to the arrow keys. I am kind of tired of seeing this obsession with trying to get everyone to use hjkl which just doesn't make any actual sense. I totally get the point about the arrow keys requiring you to lift your hand but you can accomplish the same arrow key logic while keeping your hand in the same place.
评论 #5308050 未加载
评论 #5308331 未加载
评论 #5308102 未加载
snarfy大约 12 年前
My #1 trick/recommendation? Use Control-[ instead of the Esc key. It's less hand travel and keeps your fingers on the home keys. It's all about minimizing your arm movements.<p>The same goes for hkjl. The arrow keys are too far away, that's why you use hkjl. Embrace the lazy and you'll grok vim.
评论 #5308315 未加载
评论 #5309014 未加载
a_p大约 12 年前
As someone who uses a custom variant of the Dvorak layout, one thing about Vim that I find annoying is the that the navigation keys only make sense for a Qwerty keyboard. I know that it is easy to do a custom remap but nevertheless I find that it is harder to learn the commands when the keyboard shortcuts are no longer intuitive (e.g not using d for delete, etc.)
评论 #5316439 未加载
whatshisface大约 12 年前
Google's cache: (the site is down as I am typing this.)<p><a href="http://webcache.googleusercontent.com/search?q=cache:h6o6.com/2013/03/start-groking-vim-ditch-the-arrow-keys/" rel="nofollow">http://webcache.googleusercontent.com/search?q=cache:h6o6.co...</a>
评论 #5307966 未加载
评论 #5308325 未加载
mortehu大约 12 年前
If you're spending a significant amount of time navigating with with arrows keys or hjkl, maybe you should switch on incremental search and start using /[FOO], ?[FOO], t[FOO], b, w, %, ^ and $ more. It's highly unlikely that character-by-character movement will be the fastest way to navigate.<p>Alt+character is the same as Esc followed by character if you want to speed up your escaping without using a non-standard keyboard layout.<p><a href="http://i.stack.imgur.com/uq2M1.jpg" rel="nofollow">http://i.stack.imgur.com/uq2M1.jpg</a>
armored_mammal大约 12 年前
I can't use vim effectively because I constantly try to navigate using WASD.<p>I know I can bind it, but the thought of rebinding every command and then being dependent on towing the configuration to every computer I'd ever use scares me.<p>So I use it on occasion with the same artfulness as someone on crutches trying to dance.<p>Maybe someday someone will default an 'FPS' control layout.
评论 #5308340 未加载
评论 #5308330 未加载
CoffeeDregs大约 12 年前
I have probably tried 3 times to ditch the arrows and use hjkl and I've failed each time. What is the trick to overcoming this? Perhaps it's that I've done it while at work that has caused the issue (ie. I need to be productive now!). Pick a weekend and force the switch?
评论 #5308342 未加载
评论 #5308333 未加载
评论 #5308186 未加载
评论 #5308187 未加载
评论 #5308344 未加载
bcl大约 12 年前
Go one step further. Try to stop using hjkl<p>I am not even close to being able to do this yet, but I keep reminding myself to use other movement commands and search instead. Eventually it will be faster.