Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The vi mode for Bash. Blew my mind when I discovered it and it probably saved me hundreds of hours already. I used to have multiple copies of this cheatsheet [0] at my desk for every new developer I would see editing a terminal command with the left and right arrows.

[0] https://catonmat.net/ftp/bash-vi-editing-mode-cheat-sheet.pd...



I dunno, I don't think it really gets you more than just adding some basic mappings

    # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
    "\e[1;5C": forward-word
    "\e[1;5D": backward-word
    "\e[5C": forward-word
    "\e[5D": backward-word
    "\e\e[C": forward-word
    "\e\e[D": backward-word

    ## arrow up
    "\e[A":history-search-backward
    ## arrow down
    "\e[B":history-search-forward


All of those require me to shift my hands away from the home row of the keyboard though. The real magic of vi-mode is that everything you need is right there under your fingertips 100% of the time. Well, except escape, but that is why I map caps-lock to escape ...


Ah, interesting. That's something I've never even considered before. My hands seem to just move naturally back and forth without thinking. I know that people have brought up having to move back and forth between keyboard and mouse as being a pain point, but never thought about having to move out of the home row as one as well. For me, moving back and forth between keyboard, touchpad, mouse just seems second nature. I do wish I was better at dual-wielding keyboard and mouse, though, so I've been looking into mirrorboard.


Holy shit. Thank you.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: