1. 32
  1.  

  2. 9

    There are some gems in here. 10 years a vimer and there’s still plenty to learn.

    1. 5

      One pair of normal mode commands which I find useful are g; and g, to move in the changelist.

      It happens often that I’m writing something and realize that I also need to change something else I had been editing previously, then go back to editing the current thing. g; and g, work well for that. Ctrl-O is also good to move to a previous position (not just to a change, it can be any previous jump position).

      1. 1

        Nice! I wind up doing '" and '> pretty often for sort of similar use cases, but I don’t think I knew you could work your way around the changes.

      2. 3

        Some of my personal ’intermediate vim` favorites:

        • J to collapse consecutive lines
        • block select (Ctrl-v) + edit – even if you’re not a vim user, I highly recommend getting used to it in your text editor
        • pipe command’s output to vim with command | vim -. For me it’s often faster to process the output in vim than remembering some awk/sed/cut syntax
        • :term to split the screen and run a terminal It’s actually pretty decent, both in terms of performance and it behaves ‘as you expect’ if you . You can also switch to ‘normal mode’ in the terminal with an awkward ’Ctrl-\ Ctrl-N` (e.g. then you can copy some stuff)
        • set up vi mode in your shell/interpreter (e.g. ipython). At least, for me it’s easier to just use the same bindings to edit commands + there is usually a key to open the command in vim and run after saving, useful for multi line commands
        1. 2

          Odd that it mentions control-n (autocomplete based on next match) but not control-p (autocomplete based on previous match). I’m far more likely to want to autocomplete something that I’ve typed just before the insert point than just after, so I find control-p gives the completion that I want higher up the list (usually at the top) than control-n.

          ci<char> is interesting and something I should probably learn. I typically use d% to delete bracketed things, but that requires me to be at the start or end of the block.

          S is great to mention, I think they’re assuming everyone knows s (delete the current character and insert), which I use regularly but didn’t learn until 5-10 years after I started using vim.

          A few of these (I, S, O) are variations of the same command as a lower-case thing. That’s a general pattern in vim and good to highlight: if there’s a lower-case command you use frequently, try hitting the upper-case variant and see what happens: it’s probably something useful (e.g. D deletes to the end of the current line).

          1. 1

            ci is interesting and something I should probably learn.

            You can also use cib for parens, “change inside block” is how I remember it. But yeah being able to use other chars is cool, I didn’t know you could do that.

            1. 1

              i<delimiter> is a motion that goes with any command. So di{ deletes everything inside a set of curlies, vi’ enters Visual and highlights everything inside a set of single quotes, etc.

              There’s also a<delimiter>, which is the same motion except it includes the delimiters themselves. “i” for “inside”, “a” for “around”.

              My biggest revelation using vim/evil-emacs is that it’s really a whole composable command language.

              1. 3

                i is a motion that goes with any command.

                ah, now that you say it im like “doh that should have been obvious!” but i never thought about it. thanks!

                My biggest revelation using vim/evil-emacs is that it’s really a whole composable command language.

                Absolutely, if you think of it as command hotkeys, it will be confusing, but if you think of it as composing little sentences to tell the editor what to do, then it makes a lot more sense.

                1. 2

                  To learn all of them you can :help text-objects