‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. phforms · · focus · HN ↗
    The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something.

    Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.

    1. kulahan · · focus · HN ↗
      I’ve read that if you’re trying to overturn a habit with a new habit, it’s best to undo whatever it is you did the old way, then redo it the new way.

      So if you want to use ctrl-r, but you’re using the up key, use the down key to navigate back to a clear line, then use ctrl-r. Do it enough times and your brain will work overtime to find a shortcut (aka just doing it the new way).

      1. or_am_i · · focus · HN ↗
        Temporarily binding the up arrow in the shell to echo "Use Ctrl-R" is probably the quickest way to un-/re-learn
        1. estetlinus · · focus · HN ↗
          I’ve done this, nowadays asking Claude to rebind things so that I’m forced to learn. It comes with interesting side effects!
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.