News for hackers. Stuff that matters.
Re:Snake Vim Trainer by theon144 on Friday August 16, 2013 @02:16PM (#6225766)
When I was learning vikeys, I just disabled arrowkeys in my .vimrc :)

    inoremap  <Up>     <NOP>
    inoremap  <Down>   <NOP>
    inoremap  <Left>   <NOP>
    inoremap  <Right>  <NOP>
    noremap   <Up>     <NOP>
    noremap   <Down>   <NOP>
    noremap   <Left>   <NOP>
    noremap   <Right>  <NOP>
I know it sounds masochistic, but it really isn't; I actually had to check after a while whether I really set it, because I didn't remember any issues with navigation. Try it!
Re:Snake Vim Trainer by hadem on Friday August 16, 2013 @11:33AM (#6224616)
I was about to say that the keyboard controls didn't work for me until I remembered that I had Vimium installed with Chrome.
Re:Snake Vim Trainer by coherentpony on Friday August 16, 2013 @12:00PM (#6224819)
Same for me, too. Also disable Vimium if you have RES installed.
Re:Snake Vim Trainer by bndw on Friday August 16, 2013 @12:53PM (#6225188)
ditto
Re:Snake Vim Trainer by cyphax on Friday August 16, 2013 @10:21AM (#6224124)
I certainly like VIM, it's my default editor on non-Windows operating systems, but I really don't care one bit about the h,j,k,l keymapping; I can use my arrow keys, which I find to be lots easier. So I TOTALLY suck at this game because it doesn't support the arrow keys like VIM does! :P
Re:Snake Vim Trainer by jonahx on Friday August 16, 2013 @11:08AM (#6224412)
You're missing a ton of vim's value by doing that. The reason for those key mappings is so that your hands can remain in standard "typing ready" position, so that you can both type and navigate without moving your hands. If you are moving away to the arrow keys, at that point you're one step away from just navigating by mouse: it's really missing the point.
Re:Snake Vim Trainer by eckzow on Friday August 16, 2013 @11:53AM (#6224757)
I don't know about "a ton" -- there are far better ways to move around a file than mashing hjkl, even with numbered versions (vim-easymotion, vim-seek). Once you can get to the right place in the file I almost never use hjkl with an action, but rather text objects or motions like ci" or dt;
Re:Snake Vim Trainer by swift on Friday August 16, 2013 @12:16PM (#6224929)
I've started to use relative line numbering (numbers.vim is highly recommended) and that has made me use 'j' and 'k' in motions quite frequently. I wish I had made the change earlier!
Re:Snake Vim Trainer by harrytuttle on Friday August 16, 2013 @10:29AM (#6224185)
Just to state some support for this: I have used vim for over a decade and I haven't used hjkl on a good day once. Arrow keys are fine.

Occasionally I use hjkl if the terminal is set up wrongly or it's a broken vi implementation but that's it.

Re:Snake Vim Trainer by yogo on Friday August 16, 2013 @11:20AM (#6224500)
Interesting. I'm curious as to how and what you use vim for. I find it hard to believe that anyone would seriously do something like d + down arrow with dj available. All of those seconds (it takes me more than a second to go to the arrows then back to home row) add up over time.
Re:Snake Vim Trainer by Patrick_Devine on Friday August 16, 2013 @11:38AM (#6224653)
You would use 'dd' instead which is faster since you don't have to have make sure your other hand is in the correct position.
Re:Snake Vim Trainer by yogo on Friday August 16, 2013 @12:38PM (#6225078)
My example involved deleting two lines, which you can accomplish with '2dd', 'dj', 'dddd', etc. When my hands are on my keyboard 'dj' is my personal preference. The parent poster was using arrow keys so naturally I'm wondering if for something like 'dj' he/she would use 'd + down arrow' since that seems like waste of time. It's a somewhat contrived example to see how far some users take the use of the arrow keys, which you quickly realize are not necessary in vim.
Re:Snake Vim Trainer by harrytuttle on Friday August 16, 2013 @12:10PM (#6224897)
I have a ThinkPad. The keys are closer together.

Used for most editing tasks. Those seconds are fractional compared to thinking time before cutting code. I'm not paid in words per minute.

w, g, / are used more than the arrows anyway.

Re:Snake Vim Trainer by bitcrusher on Friday August 16, 2013 @02:49PM (#6225987)
It depends on your keyboard as well. I use a Kinesis Advantage, which has the arrow keys in a place that doesn't require movement from your hands, so hjkl doesn't provide the advantage that it used to.
Re:Snake Vim Trainer by zachgersh on Friday August 16, 2013 @10:25AM (#6224149)
This should get you comfortable with using the h,j,k,l mapping then. I actually turn arrow keys off in my vimrc, I can definitively say it is one of the things that has made me faster.
Re:Snake Vim Trainer by oftenwrong on Friday August 16, 2013 @11:33AM (#6224610)
Do not turn them off; remap them! That is valuable keyboard real estate.

I use them for buffer switching, since I do that frequently. Left and right change to the next and previous buffers, respectively. Down to quickly swap to the previously focused buffer. Up to bring up a buffer switch menu. Here are the .vimrc lines:

    " Arrow keys for buffer switching
    nnoremap <left> :bprev<cr>
    nnoremap <right> :bnext<cr>
    nnoremap <down> :buffer #<cr>
    nnoremap <up> :buffers<cr>:buffer<space>
Re:Snake Vim Trainer by zachgersh on Friday August 16, 2013 @11:40AM (#6224669)
Such a good call! I don't use buffers enough :)
Re:Snake Vim Trainer by jonahx on Friday August 16, 2013 @12:27PM (#6224997)
Great tip!
Re:Snake Vim Trainer by cyphax on Friday August 16, 2013 @10:28AM (#6224179)
Good point about using this to get me comfortable with the keymapping. I dunno if I'll get too depressed from dying over and over before I get the hang of it though! ;)
Re:Snake Vim Trainer by aith on Friday August 16, 2013 @10:33AM (#6224206)
Getting frustrated and depressed with keymapping? Sounds just like my experience using real vim ;)
Re:Snake Vim Trainer by JimmaDaRustla on Friday August 16, 2013 @11:25AM (#6224539)
I got the pitch forks, who has the torches?
Re:Snake Vim Trainer by carlmro on Friday August 16, 2013 @01:30PM (#6225456)
The game is fun, but perhaps a bit misleading regarding what 'mastering vim movement' amounts to. As I am sure many of you know, vim has tons of constructs for efficient navigation: Using b or w for word-wise jumping, special markers like $ and 0, Ctrl-D and Ctrl-U etc. A good overview of movement commands can be found here: http://vim.wikia.com/wiki/Moving_around
Re:Snake Vim Trainer by dllthomas on Friday August 16, 2013 @02:50PM (#6225992)
Right. For it to really feel like vim movement, I'd push two keys and the snake would jump to the next food pellet in insert mode...
Re:Snake Vim Trainer by aith on Friday August 16, 2013 @10:18AM (#6224102)
I made this site at Dev Bootcamp Chicago. It's super simple, but if it brings someone any amount of entertainment, it'll make my day.

The snake part is a HTML5 canvas, and the back end is Ruby/Sinatra.

Enjoy!

Re:Snake Vim Trainer by boushley on Friday August 16, 2013 @10:33AM (#6224207)
This is awesome! You should add ctrl+[ as an alias for escape as vim does. I've used that for a while now, and actually reaching up for escape feels unnatural now.
Re:Snake Vim Trainer by nils_ on Friday August 16, 2013 @10:39AM (#6224241)
I was thinking the same thing. Not being able to use ctrl+[ actually made this game really really hard for me as my muscle memory screams in protests each time i want to exit insert mode.
Re:Snake Vim Trainer by dllthomas on Friday August 16, 2013 @02:54PM (#6226019)
Ctrl+[ isn't an alias for escape, it is escape on traditional terminals (and a whole lot of terminal emulators). It's useful to know this when using a keyboard that lacks an escape key.
Re:Snake Vim Trainer by Arnor on Friday August 16, 2013 @10:35AM (#6224217)
Thanks for the VIM tip! I never even thought of looking for an alias for esc before.
Re:Snake Vim Trainer by NoodleIncident on Friday August 16, 2013 @11:00AM (#6224373)
I aliased jk to ESC. Can that be added in?
Re:Snake Vim Trainer by yogo on Friday August 16, 2013 @11:13AM (#6224447)
Out of habit I used jj to escape. A touch of inoremap would help this game :)
Re:Snake Vim Trainer by andrv on Friday August 16, 2013 @11:14AM (#6224456)
did this recently and it's been very useful. if anyone's interested ('kj' is faster for me), add to ~/.vimrc:

inoremap kj <ESC>

Re:Snake Vim Trainer by aith on Friday August 16, 2013 @10:40AM (#6224255)
Easy! I'll add this today
Re:Snake Vim Trainer by shime on Friday August 16, 2013 @12:10PM (#6224898)
why don't you map escape to caps lock?
Re:Snake Vim Trainer by paulnechifor on Friday August 16, 2013 @12:31PM (#6225023)
This is what I do too. Caps lock is a mistake anyway. The keyboards vi was written on had ESC where the tab key is on most keyboards now[1].

[1] http://en.wikipedia.org/wiki/File:KB_Terminal_ADM3A.svg

Re:Snake Vim Trainer by deathanatos on Friday August 16, 2013 @03:46PM (#6226324)
And if you're one of those skeptics that thinks "but I sometimes use caps lock to type C_STYLE_CONSTANTS, and I need it!", there's a wonderful thing I call two-shift caps lock: you press both shift keys at the same time, and it toggles caps lock. Now you have your Shift keys, and your caps lock, and a key that really truly has no purpose. Now go forth into the world, and remap thy keyboard.

In GNOME: System → Preferences → Keyboard; Layouts; Options; Miscellaneous compatibility options → "Both Shift-Keys together toggle Caps Lock" (You can also remap Caps Lock in this same dialog, so the change isn't just for Vim. It's under "Caps Lock key behavior". Also, having a compose key is awesome.)

Re:Snake Vim Trainer by ejk314 on Friday August 16, 2013 @04:24PM (#6226568)
Is there a way to do this without installing addons to vim?
Re:Snake Vim Trainer by ilikepi on Friday August 16, 2013 @12:32PM (#6225029)
I find I'm having a mental conflict between Vim's hjkl controls and WASD-style gaming controls, despite having very little experience using the latter with my right hand. This is made worse since it happens to be 'i' that my right-hand middle finger hits when I think "go up".

Very neat though, regardless!

Re:Snake Vim Trainer by McPants on Friday August 16, 2013 @12:56PM (#6225214)
This is what is preventing me from learning Vim. I play games every day using WASD movement and if I have to switch to hjkl my brain goes haywire.

I have been waiting for someone to create a Vim control scheme that relies on WASD movement and maybe also brings in other common gaming related keys (E for insert?, space for escape?) To me this seems more logical than hjkl/i/esc.

Until then though it just feels like more work that it needs to be for me to personally learn Vim. Which is a shame because I can recognize how useful it can be, especially after watching Destroy all Software screencasts.

Re:Snake Vim Trainer by Stealth- on Friday August 16, 2013 @01:14PM (#6225340)
I do both regularly. They are different hands and the different movements actually become very different feeling. When my right hand is on the mouse, WASD feels natural. Otherwise, I naturally hold my left hand near the ESC key and my right hand over HJKL.

Because it's the home row, it also feels more natural when you are getting ready to type. The mental separation between "gaming" and "typing" is not hard to get a hold of really quick. Give it a try! I guarantee you'll be completely used to it within a week.

Also, keep in mind all of these keys can be remapped in Vim anyways :)

Re:Snake Vim Trainer by McPants on Friday August 16, 2013 @06:38PM (#6227124)
It seems like that person I have been waiting for to create that mapping is me!
Re:Snake Vim Trainer by ehsanu1 on Saturday August 17, 2013 @07:21AM (#6228788)
I had the same issue. Here's my config to solve it (ijkl become like arrow keys, h is insert instead):

    map k g<Down>
    map i g<Up>
    map j <Left>
    noremap h i
Note that with this config, we maintain the normal mode "inner" text objects with "h" instead of "i". So where you would previous type di' to delete inside quotes, now you'll dh'. And dh( instead of di(, etc. It all works, and I've been using this config for a couple years now.
Re:Snake Vim Trainer by jcurbo on Friday August 16, 2013 @01:44PM (#6225552)
I just tried the sname game and had the same experience (although I use ESDF for controls). My brain is not used to using my right hand for directional control.

That said it should be easy to remap vim keys to use WASD/etc - although there might be conflicts with other functions.

Re:Snake Vim Trainer by thezilch on Friday August 16, 2013 @05:56PM (#6226956)
Having the same mental problem myself, even with a decade or more of both esdf and hjkl, and I'm now wondering if I should or could switch i and h -- switch input mode to h.
Re:Snake Vim Trainer by ehsanu1 on Saturday August 17, 2013 @07:24AM (#6228792)
You can, please see my reply to your parent.
Re:Snake Vim Trainer by bluedino on Friday August 16, 2013 @01:07PM (#6225289)
It's left hand vs right hand, though.
Re:Snake Vim Trainer by ottocode on Friday August 16, 2013 @11:12AM (#6224442)
This is awesome. I thought I was pretty good at vim, but the added pressure of needing to switch modes and directions at the same time without thinking about the keys was a great learning experience! (and fun game too!)
Re:Snake Vim Trainer by pit on Friday August 16, 2013 @03:24PM (#6226203)
In light of the recent comments about mods editing article titles, I gotta say that when I saw this earlier today I didn't think it sounded interesting. After the rename, I clicked on it, and man, it's awesome.
Re:Snake Vim Trainer by guard-of-terra on Friday August 16, 2013 @01:14PM (#6225343)
vim and BSDs default configurations insisting on inexistance of arrow keys is a "tradition" not completely unlike clitoridectomy. Come on guys (and gals), we've been over this already.
Re:Snake Vim Trainer by lubomir on Friday August 16, 2013 @01:36PM (#6225496)
It is not insisting. Vim will happilly let you use the arrow keys. It's just that once you acclimate to "hjkl", it is slightly faster and more comfortable, since you don't need to move right hand anywhere while typing. Or at least that's how it works for me.
Re:Snake Vim Trainer by IanCal on Friday August 16, 2013 @01:46PM (#6225559)
It is completely unlike that, please don't compare not having arrow keys to genital mutilation.
Re:Snake Vim Trainer by Millennium on Friday August 16, 2013 @02:12PM (#6225750)
There's a thing called perspective that you may want to consider exploring. Remapping the arrow keys is a minor annoyance at worst.
Re:Snake Vim Trainer by coldpie on Friday August 16, 2013 @01:38PM (#6225509)
What? The arrow keys work fine. They're just waaaaay over there. Why do you want to use them?
Re:Snake Vim Trainer by guard-of-terra on Friday August 16, 2013 @03:39PM (#6226295)
They're rather waaay on my keyboard where my right hand is.

What I'm talking about is deliberate crippled default configurations.

Re:Snake Vim Trainer by cgag on Friday August 16, 2013 @01:53PM (#6225606)
As I recall being forced to use the homerow in typing class was just like being circumcised.
Re:Snake Vim Trainer by sdkmvx on Friday August 16, 2013 @04:54PM (#6226688)
Your terminal is probably not correctly configured. Remember that real terminals did not originally have arrow keys or home end keys or really anything that's not in ASCII. If you're actually using a termcap old enough that it doesn't know about those escape sequences (maybe Solaris and other commercial UNIX offerings), or you're using a more recent termcap but your $TERM is set to something ancient, then the escape sequences are not interpreted.

Of course UNIX terminal handling is not standardized at all, so you may find that some programs ignore $TERM and do their own thing.

Re:Snake Vim Trainer by guard-of-terra on Friday August 16, 2013 @05:55PM (#6226949)
$TERM is a joke when you're on ssh (and that's always). It's always "xterm" but there is a huge variation between those xterms and key codes seems to be altered as they pass down the chain.

Is Home ^]]1~ or it's ^]H? You have to guess every time.

Re:Snake Vim Trainer by phowat on Friday August 16, 2013 @01:38PM (#6225507)
You can use the arrows in vim by default, no problem with that. For example, all my current co-workers use vim and I'm the only one who navigates using HJKL. With that said, I really really recommend any vim user to at least give a shot at using it instead of arrow keys. YMMV, but for me, not having to reach for the arrows help me stay in the zone.
Re:Snake Vim Trainer by guard-of-terra on Friday August 16, 2013 @03:38PM (#6226282)
Some distros/OSes ship with unmapped arrow keys and broken home/end in the terminal. This is seriously bad for your health.
Re:Snake Vim Trainer by w0ts0n on Friday August 16, 2013 @10:24AM (#6224143)
On Firefox, It just goes right through the "food"
Re:Snake Vim Trainer by aith on Friday August 16, 2013 @10:26AM (#6224164)
You have to be in INSERT mode (press i) to eat the food. That catch is that you can't change direction in INSERT mode. Press 'esc' to get out of INSERT mode.
Re:Snake Vim Trainer by c-oreills on Friday August 16, 2013 @10:26AM (#6224154)
That's what insert mode is for.
Re:Snake Vim Trainer by clubhi on Friday August 16, 2013 @04:44PM (#6226657)
A good way for me to learn movement is to think of direction as:

walking up stairs: kl kl kl kl kl kl kl walking down stairs: jh jh jh jh jh jh jh jh jh

Re:Snake Vim Trainer by barbs on Friday August 16, 2013 @06:25PM (#6227072)
I played Nethack on a MacBook Pro (with no number-pad) to get used to the vim movement keys.
Re:Snake Vim Trainer by andrew_wc_brown on Friday August 16, 2013 @07:37PM (#6227479)
I use vim everyday and I don't find this game easy to play.
Re:Snake Vim Trainer by dllthomas on Friday August 16, 2013 @02:55PM (#6226025)
robots, and later nethack, served this purpose for me as a child... likely less effectively.
Re:Snake Vim Trainer by yefim on Friday August 16, 2013 @01:01PM (#6225242)
topscore never seems to update.

Try `$.post('/newtop', {score: 16000})`

Re:Snake Vim Trainer by bndw on Friday August 16, 2013 @12:54PM (#6225200)
leaderboard doesn't appear to update (at least in real time).
Re:Snake Vim Trainer by snake_plissken on Friday August 16, 2013 @12:29PM (#6225008)
you just had to go with something different than WASD didntcha?
Re:Snake Vim Trainer by TallboyOne on Friday August 16, 2013 @12:23PM (#6224971)
That game is impossible